Back up your Uyuni installation regularly, in order to prevent data loss.
Because Uyuni relies on a database as well as the installed program and configurations, it is important to back up all components of your installation.
This chapter contains information on the files you need to back up, and introduces the smdba tool to manage database backups.
It also contains information about restoring from your backups in the case of a system failure.
Regardless of the backup method you use, you must have available at least three times the amount of space your current installation uses. Running out of space can result in backups failing, so check this often.
The most comprehensive method for backing up your Uyuni installation is to back up the relevant files and directories. This can save you time in administering your backup, and can be faster to reinstall and re-synchronize in the case of failure. However, this method requires significant disk space and could take a long time to perform the backup.
If you want to only back up the required files and directories, use this list:
To make this process simpler, and more comprehensive, we recommend backing up the entire /etc and /root directories, not just the ones specified here.
/etc/cobbler/
/etc/dhcp.conf
/etc/fstab and any ISO mountpoints you require.
/etc/rhn/
/etc/salt
/etc/sudoers
/etc/sysconfig/rhn/
/root/.gnupg/
/root/.ssh
This file exists if you are using an SSH tunnel or SSH push. You will also need to have saved a copy of the id-susemanager key.
/root/ssl-build/
/srv/pillar
/srv/salt
/srv/tftpboot/
/srv/www/cobbler
/srv/www/htdocs/pub/
/var/lib/cobbler/
/var/lib/rhn/kickstarts/
/var/spacewalk/
Any directories containing custom data (such as scripts, Kickstart profiles, AutoYaST, and custom RPMs).
You will also need to back up your database, which you can do by copying /var/spacewalk/db-backup or by using the smdba tool, which is explained later in this chapter.
Re-install Uyuni
Re-synchronize your installation with the mgr-sync tool.
You can choose to re-register your product, or skip the registration and SSL certificate generation sections.
Re-install the /root/ssl-build/rhn-org-httpd-ssl-key-pair-MACHINE_NAME-VER-REL.noarch.rpm package.
Schedule the re-creation of search indexes next time the rhn-search service is started:
rcrhn-search cleanindex
If you did not have /var/spacewalk/packages/ in your backup, but the source repository still exists, you can restore it by performing a complete channel synchronization.
The smdba tool is used for managing a local PostgreSQL database.
It allows you to back up and restore your database, and manage backups.
It can also be used to check the status of your database, and perform administration tasks, such as restarting.
The smdba tool works with local PostgreSQL databases only, it will not work with remotely accessed databases, or Oracle databases.
The smdba tool requires sudo access, in order to execute system changes.
Ensure you have enabled sudo access for the admin user before you begin, by checking the /etc/sudoers file for this line:
admin ALL=(postgres) /usr/bin/smdba
Check the runtime status of your database with the smdba db-status command.
This command will return either online or offline:
smdba db-status Checking database core... online
To check the full connection to the database, use the smdba db-check command.
Depending on your environment, this command will report on the status of listeners, in addition to connectivity status.
smdba db-check
Starting and stopping the database can be performed with smdba db-start and smdba db-stop
smdba db-start Starting core... done
smdba db-stop Stopping the SUSE Manager database... Stopping core: done
The smdba tool performs a continuous archiving backup.
This backup method combines a log of every change made to the database during the current session, with a series of more traditional backup files.
When a crash occurs, the database state is first restored from the most recent backup file on disk, then the log of the current session is replayed exactly, to bring the database back to a current state.
A continuous archiving backup with smdba is performed with the database running, so there is no need for downtime.
This method of backing up is stable and generally creates consistent snapshots, however it can take up a lot of storage space.
Ensure you have at least three times the current database size of space available for backups.
You can check your current database size by navigating to /var/lib/pgsql/ and running df -h.
The smdba tool also manages your archives, keeping only the most recent backup, and the current archive of logs.
The log files can only be a maximum file size of 16 MB, so a new log file will be created once the files reach this size.
Every time you create a new backup, previous backups will be purged to release disk space.
We recommend you use cron to schedule your smdba backups to ensure that your storage is managed effectively, and you always have a backup ready in case of failure.
The smdba tool can be run directly from the command line.
We recommend you run a manual database backup immediately after installation, or if you have made any significant changes to your configuration.
When smdba is run for the first time, or if you have changed the location of the backup, it will need to restart your database before performing the archive.
This will result in a small amount of downtime.
Note that regular database backups will not require any downtime.
Allocate permanent storage space for your backup. In this procedure, we will be using an NFS share located at /var/spacewalk/.
This will become a permanent target for your backup, so ensure it will remain accessible by your server at all times.
In your backup location, create a directory for the backup:
sudo -u postgres mkdir /var/spacewalk/db-backup
Or, as root:
install -d -o postgres /var/spacewalk/db-backup
Ensure you have the correct permissions set on the backup location:
chown postgres:postgres /var/spacewalk/db-backup
To run a backup for the first time, run the smdba backup-hot command with the enable option set.
This will create the backup in the specified directory, and, if necessary, restart the database:
smdba backup-hot --enable=on --backup-dir=/var/spacewalk/db-backup
Check that the backup files exist in the /mnt/backup/database directory, to ensure that your backup has been successful.
You do not need to shut down your system in order to perform a database backup with smdba.
However, because it is a large operation, database performance can slow down while the backup is running.
We recommend you schedule regular database backups for a low-traffic period, to minimize disruption.
Ensure you have at least three times the current database size of space available for backups.
You can check your current database size by navigating to /var/lib/pgsql/ and running df -h.
Create a directory for the backup, and set the appropriate permissions:
# mkdir /var/spacewalk/db-backup # chown -R postgres:postgres /var/spacewalk/db-backup # chmod 700 /var/spacewalk/db-backup
Open /etc/cron.d/db-backup-mgr, or create it if it doesn’t exist, and add the following line to create the cron job:
0 2 * * * root /usr/bin/smdba backup-hot --enable=on --backup-dir=/var/spacewalk/db-backup
Check the backup directory regularly to ensure the backups are working as expected.
The smdba tool can be used to restore from backup in the case of failure.
Shutdown the database:
smdba db-stop
Start the restore process and wait for it to complete:
smdba backup-restore start
Restart the database:
smdba db-start
Check if there are differences between the RPMs and the database.
spacewalk-data-fsck
In SUSE Manager
with an embedded database, archive logging is enabled by default.
This feature allows the database management tool smdba to perform hot backups.
With archive log enabled, even more data is stored on the hard disk:
Postgresql maintains a limited number of archive logs. Using the default configuration, approx. 64 files with a size of 16 MiB are stored.
Creating a user and syncing the channels:
SLES12-SP2-Pool-x86_64
SLES12-SP2-Updates-x86_64
SLE-Manager-Tools12-Pool-x86_64-SP2
SLE-Manager-Tools12-Updates-x86_64-SP2
Postgresql will generate an additional ~1 GB of data. So it is important to think about a backup strategy and create a backups in a regular way.
Archive logs are stored at:
/var/lib/pgsql/data/pg_xlog/ (postgresql)
Database administrators may use the subcommand space-overview to get a report about occupied table spaces, for example:
smdba space-overview SUSE Manager Database Control. Version 1.5.2 Copyright (c) 2012 by SUSE Linux Products GmbH Tablespace | Size (Mb) | Avail (Mb) | Use % ------------+-----------+------------+------ postgres | 7 | 49168 | 0.013 susemanager | 776 | 48399 | 1.602
The following command is available for Postgresql.
For a more detailed report, use the space-tables subcommand.
It lists the table and its size, for example:
smdba space-tables SUSE Manager Database Control. Version 1.5.2 Copyright (c) 2012 by SUSE Linux Products GmbH Table | Size --------------------------------------+----------- public.all_primary_keys | 0 bytes public.all_tab_columns | 0 bytes public.allserverkeywordsincereboot | 0 bytes public.dblink_pkey_results | 0 bytes public.dual | 8192 bytes public.evr_t | 0 bytes public.log | 32 kB ...
It is possible to move the database to another location. For example if your database storage space is running low. The following procedure will guide you through moving the database to a new location for use by SUSE Manager.
The default storage location for SUSE Manager is: /var/lib/pgsql/ . You would like to move it, for example to: /storage/postgres/ . To begin, stop the running database with:
# rcpostgresql stop
Shutdown running spacewalk services with:
# spacewalk-service stop
Copy the current working directory structure with the following syntax:
cp [OPTION]... SOURCE... DIRECTORY
using the -a, --archive option.
For example:
# cp -ar /var/lib/pgsql/ /storage/postgres/
This command will copy the contents of /var/lib/pgsql/
to /storage/postgres/pgsql/
.
The contents of the /var/lib/pgsql needs to remain the same or the SUSE Manager database may malfunction. You also should ensure there is enough available disk space.
Mount the new database directory with:
# mount /storage/postgres/pgsql
Make sure ownership is postgres:postgres and not root:root by changing to the new directory and running the following command:
/var/lib/pgsql/ # cd /storage/postgres/pgsql/ /storage/postgres/pgsql/ # l total 8 drwxr-x--- 4 postgres postgres 47 Jun 2 14:35 ./
Add the new database mount location to your servers fstab by editing etc/fstab .
Start the database with:
# rcpostgresql start
Start spacewalk-services with:
# spacewalk-service start
This section provides guidance on restoring your server after its root partition has crashed.
This section assumes you have setup your server similar to the procedure explained in Getting Started guide with separate partitions for the database and for channels mounted at /var/lib/pgsql
and /var/spacewalk/
.
Start by installing SLES12 SP2 and the SUSE Manager Extension. Do not mount the /var/spacewalk and /var/lib/pgsql partitions.
Once installation of SUSE Manager has completed shutdown services with spacewalk-service shutdown and the database with rcpostgresql stop.
Mount your /var/spacewalk and /var/lib/pgsql partitions and restore the directories listed in section one.
Start SUSE Manager services and the database with spacewalk-services start and rcpostgresql start
SUSE Manager should now operate normally without loss of your database or synced channels.
The information for connecting to the SUSE Manager database is located in /etc/rhn/rhn.conf
:
db_backend = postgresql db_user = susemanager db_password = susemanager db_name = susemanager db_host = localhost db_port = 5432 db_ssl_enabled =