oVirt engine备份与恢复官方文档

来源:互联网 发布:python sys.argv[1] 编辑:程序博客网 时间:2024/04/29 06:47

Backups

Backing Up and Restoring oVirt

Backing up oVirt - Overview

While taking complete backups of the machine on which oVirt is installed is recommended whenever changing the configuration of that machine, a utility is provided for backing up only the key files related to oVirt. This utility - the engine-backup command - can be used to rapidly back up the engine database and configuration files into a single file that can be easily stored.

Syntax for the engine-backup Command

The engine-backup command works in one of two basic modes:

# engine-backup --mode=backup
# engine-backup --mode=restore

These two modes are further extended by a set of parameters that allow you to specify the scope of the backup and different credentials for the engine database. A full list of parameters and their function is as follows:

Basic Options

--mode
Specifies whether the command will perform a backup operation or a restore operation. Two options are available - backup, and restore. This is a required parameter.
--file
Specifies the path and name of a file into which backups are to be taken in backup mode, and the path and name of a file from which to read backup data in restore mode. This is a required parameter in both backup mode and restore mode.
--log
Specifies the path and name of a file into which logs of the backup or restore operation are to be written. This parameter is required in both backup mode and restore mode.
--scope
Specifies the scope of the backup or restore operation. There are two options - all, which backs up both the engine database and configuration data, and db, which backs up only the engine database.

Database Options

The following options are only available when using the engine-backup command in restore mode.

--change-db-credentials
Allows you to specify alternate credentials for restoring the engine database using credentials other than those stored in the backup itself. Specifying this parameter allows you to add the following parameters.
--db-host
Specifies the IP address or fully qualified domain name of the host on which the database resides. This is a required parameter.
--db-port
Specifies the port by which a connection to the database will be made.
--db-user
Specifies the name of the user by which a connection to the database will be made. This is a required parameter.
--db-passfile
Specifies a file containing the password by which a connection to the database will be made. Either this parameter or the --db-password parameter must be specified.
--db-password
Specifies the plain text password by which a connection to the database will be made. Either this parameter or the --db-passfile parameter must be specified.
--db-name
Specifies the name of the database to which the database will be restored. This is a required parameter.
--db-secured
Specifies that the connection with the database is to be secured.
--db-secured-validation
Specifies that the connection with the host is to be validated.

Help

--help
Provides an overview of the available modes, parameters, sample usage, how to create a new database and configure the firewall in conjunction with backing up and restoring oVirt.

Creating a Backup with the engine-backup Command

Summary

The process for creating a backup of the engine database and the configuration data for oVirt using the engine-backup command is straightforward and can be performed while oVirt is active.

Procedure 12.1. Backing up oVirt

  1. Log on to the machine running oVirt.
  2. Run the following command to create a full backup:
    Example 12.1. Creating a Full Backup
    # engine-backup --scope=all --mode=backup --log=[file name] --file=[file name]

    Alternatively, run the following command to back up only the engine database:
    Example 12.2. Creating an engine database Backup

    # engine-backup --scope=db --mode=backup --log=[file name] --file=[file name]

Result

tar file containing a backup of the engine database, or the engine database and the configuration data for oVirt, is created using the path and file name provided.

Restoring a Backup with the engine-backup Command

While the process for restoring a backup using the engine-backup command is straightforward, it involves several additional steps in comparison to that for creating a backup depending on the destination to which the backup is to be restored. For example, the engine-backup command can be used to restore backups to fresh installations of oVirt, on top of existing installations of oVirt, and using local or remote databases.

Important: Backups can only be restored to environments of the same major release as that of the backup. For example, a backup of an oVirt version 3.3 environment can only be restored to another oVirt version 3.3 environment. To view the version of oVirt contained in a backup file, unpack the backup file and read the value in the version file located in the root directory of the unpacked files.

Restoring a Backup to a Fresh Installation

Summary

The engine-backup command can be used to restore a backup to a fresh installation of oVirt. The following procedure must be performed on a machine on which the base operating system has been installed and the required packages for oVirt have been installed, but the engine-setup command has not yet been run. This procedure assumes that the backup file can be accessed from the machine on which the backup is to be restored.

Note: The engine-backup command does not handle the actual creation of the engine database or the initial configuration of the postgresqlservice. Therefore, these tasks must be performed manually as outlined below when restoring a backup to a fresh installation.

Procedure 12.2. Restoring a Backup to a Fresh Installation

  1. Log on to the machine on which oVirt is installed.
  2. Manually create an empty database to which the database in the backup can be restored and configure the postgresql service:
    1. Run the following commands to initialize the postgresql database, start the postgresql service and ensure this service starts on boot:
      # service postgresql initdb# service postgresql start# chkconfig postgresql on
    2. Run the following commands to enter the postgresql command line:
      # su postgres$ psql
    3. Run the following command to create a new user:
      postgres=# create role [user name] with login encrypted password '[password]';
    4. Run the following command to create the new database:
      postgres=# create database [database name] owner [user name] template template0 encoding 'UTF8' lc_collate 'en_US.UTF-8' lc_ctype 'en_US.UTF-8';
    5. Edit the /var/lib/pgsql/data/pg_hba.conf file as follows:
      • For local databases, replace the existing directives in the section starting with Local at the bottom of the file with the following directives:
        host    [database name]    [user name]    0.0.0.0/0  md5host    [database name]    [user name]    ::0/0      md5
      • For remote databases, add the following line immediately underneath the line starting with Local at the bottom of the file, replacingX.X.X.X with the IP address of oVirt:
        host    [database name]    [user name]    X.X.X.X/32   md5
    6. Run the following command to restart the postgresql service:
      # service postgresql restart
  3. Restore the backup using the engine-backup command with the --change-db-credentials parameter to pass the credentials of the new database:
    # engine-backup --mode=restore --file=[file name] --log=[file name] --change-db-credentials --db-host=[database location] --db-name=[database name] --db-user=[user name] --db-password=[password]

    If successful, the following output displays:

    You should now run engine-setup.Done.
  4. Run the following command and follow the prompts to configure oVirt:
    # engine-setup

Result

The engine database and configuration files for oVirt have been restored to the version in the backup.

Restoring a Backup to Overwrite an Existing Installation

Summary

The engine-backup command can restore a backup to a machine on which oVirt has already been installed and set up. This is useful when you have taken a backup up of an installation, performed changes on that installation and then want to restore the installation from the backup.

Note: When restoring a backup to overwrite an existing installation, you must run the engine-cleanup command to clean up the existing installation before using the engine-backup command. Because the engine-backup command only cleans the engine database, and does not drop the database or delete the user that owns that database, you do not need to create a new database or specify the database credentials because the user and database already exist.


Procedure 12.3. Restoring a Backup to Overwrite an Existing Installation

  1. Log on to the machine on which oVirt is installed.
  2. Run the following command and follow the prompts to remove the configuration files for and clean the database associated with oVirt:
    # engine-cleanup
  3. Restore the backup using the engine-backup command:
    # engine-backup --mode=restore --file=[file name] --log=[file name]

    If successful, the following output displays:

    You should now run engine-setup.Done.
  4. Run the following command and follow the prompts to re-configure the firewall and ensure the ovirt-engine service is correctly configured:
    # engine-setup

Result

The engine database and configuration files for oVirt have been restored to the version in the backup.

Restoring a Backup with Different Credentials

Summary

The engine-backup command can restore a backup to a machine on which oVirt has already been installed and set up, but the credentials of the database in the backup are different to those of the database on the machine on which the backup is to be restored. This is useful when you have taken a backup of an installation and want to restore the installation from the backup to a different system.

Important: When restoring a backup to overwrite an existing installation, you must run the engine-cleanup command to clean up the existing installation before using the engine-backup command. Because the engine-backup command only cleans the engine database, and does not drop the database or delete the user that owns that database, you do not need to create a new database or specify the database credentials because the user and database already exist. However, if the credentials for the owner of the engine database are not known, you must change them before you can restore the backup.

Procedure 12.4. Restoring a Backup with Different Credentials

  1. Log on to the machine on which oVirt is installed.
  2. Run the following command and follow the prompts to remove the configuration files for and clean the database associated with oVirt:
    # engine-cleanup
  3. Change the password for the owner of the engine database if the credentials of that user are not known:
    1. Run the following commands to enter the postgresql command line:
      # su postgres$ psql
    2. Run the following command to change the password of the user that owns the engine database:
      postgres=# alter role [user name] encrypted password '[new password]';
  4. Restore the backup using the engine-backup command with the --change-db-credentials parameter:
    # engine-backup --mode=restore --file=[file name] --log=[file name] --change-db-credentials --db-host=[database location] --db-name=[database name] --db-user=[user name] --db-password=[password]

    If successful, the following output displays:

    You should now run engine-setup.Done.
  5. Run the following command and follow the prompts to re-configure the firewall and ensure the ovirt-engine service is correctly configured:
    # engine-setup

Result

The engine database and configuration files for oVirt have been restored to the version in the backup using the supplied credentials, and oVirt has been configured to use the new database.

Manually Backing Up and Restoring oVirt

Backing Up the Engine Database Using the backup.sh Script

Summary

oVirt includes a script to automate database backups. Using this script on your Manager server, you can protect yourself against potential data loss.

Procedure 12.5. Backing up the engine database using the backup.sh script

  1. Change into the /usr/share/ovirt-engine/dbscripts/ directory.
  2. Invoke backup.sh with the -h parameter to see the available options.
    Usage: backup.sh [-h] [-s SERVERNAME] [-p PORT] [-d DATABASE] [-l DIR] -u USERNAME [-v]     -s SERVERNAME - The database servername for the database (def. localhost)    -p PORT       - The database port for the database       (def. 5432)    -d DATABASE   - The database name                        (def. engine)    -u USERNAME   - The username for the database.    -v            - Turn on verbosity (WARNING: lots of output)    -l DIR        - Backup file directory.     -h            - This help text.for more options please run pg_dump --help
  3. Invoke the backup.sh command again with parameters appropriate for your environment. If you are backing up the local engine database, the-s, -p, and -d parameters are not necessary. Use the -l to specify the backup directory. This will cause a .sql file to be created in the directory you give.
  4. Copy the .sql you just created from the directory you specified to a safe remote location.

Result

You have used the backup.sh script to backup your engine database.

Backing Up Manager Configuration Files

oVirt stores customized configurations as configuration files. These configuration files contain specific configuration details regarding a given environment, and must be backed up.

Table 12.1. Files and directories that must be backed up

LocationOverview/etc/ovirt-engine/A directory containing oVirt configuration files such as engine-config.conf./etc/yum/pluginconf.d/versionlock.listA file containing version information about currently installed oVirt components./etc/pki/ovirt-engine/Security certificates provided by oVirt to clients./usr/share/jasperreports-server-pro/buildomatic/A directory containing files required to build the oVirt reports server./var/lib/ovirt-engine/backups/A directory containing backup files./var/tmp/ovirt-engine/deployments/A directory containing information on deployments./usr/share/ovirt-engine-reports/A directory containing configuration files related to reports. In particular, this directory contains sub-directories in which the credentials of the reports user are stored in a plain text, human-readable format./root/.rndA random seed file used to generate secure certificates./var/log/ovirt-engine/setup/A directory containing logs that contain the answers you gave to the setup configuration questions. You must use these files when restoring oVirt because they supply the same information that was used to initially configure oVirt.

When you have backed up all the above files and directories, you can recover oVirt to a working state after an unforeseen event.

Restoring the Engine Database Using the restore.sh Script

Summary

oVirt includes a script to automate database restoration. Using this script on your Manager server, you can recover from database corruption.

Procedure 12.6. Restoring the Engine Database Using the restore.sh Script

  1. Change into the /usr/share/ovirt-engine/dbscripts/ directory.
  2. Invoke restore.sh with the -h parameter to see the available options.
    Usage: restore.sh [-h] [-s SERVERNAME] [-p PORT] -u USERNAME -d DATABASE -f FILE [-r]     -s SERVERNAME - The database servername for the database (def. localhost)    -p PORT       - The database port for the database       (def. 5432)    -u USERNAME   - The username for the database.    -d DATABASE   - The database name    -f File       - Backup file name to restore from.     -r            - Remove existing database with same name    -h            - This help text.for more options please run pg_restore --help
  3. Invoke the restore.sh command again with parameters appropriate for your environment. If you are restoring the local engine database, the -sand -p parameters are not necessary. Use the -d to specify name of the database you are creating. oVirt expects a primary database namedengine. Use the -f to specify the .sql file you are restoring from.

Result

You have used the restore.sh script to restore your engine database.

Restoring oVirt Configuration Files

Summary

Restore a backed up copy of configuration files to oVirt.

Procedure 12.7. Restoring oVirt Configuration Files

  1. Stop the engine service:

    # service ovirt-engine stop
  2. Completely remove all previous installations of oVirt:
    # yum remove ovirt-engine
  3. Remove /etc/pki/ovirt-engine:
    # rm -rf /etc/pki/ovirt-engine
  4. Remove the main ovirt-engine directory:
    # rm -rf /etc/ovirt-engine
  5. Install oVirt:
    # yum install -y ovirt-engine
  6. Run engine-setup, giving the same answers as when you originally installed ovirt-engine:
    # engine-setup

    Your answers can be found in /var/log/engine-setup-SETUP-DATE.log, which you backed up.
  7. Stop the engine service, which was restarted as a part of the previous command:
    # service ovirt-engine stop
  8. Restore the backed up configuration files to their original locations.
  9. Make sure the ownership of the .truststore file is correct:
    # chown ovirt:ovirt /etc/pki/ovirt-engine/.truststore
  10. Make sure the permissions of the ovirt-engine-notifier.conf file is correct:
    # chmod 640 /usr/share/ovirt-engine/services/ovirt-engine-notifier/ovirt-engine-notifier.conf
  11. Start the engine service:
    # service ovirt-engine start

Result

You have restored a backed up copy of configuration files to oVirt.

0 0
原创粉丝点击