Senin, 24 Agustus 2020

RHV-backup restore engine

 

Backing up and restoring RHEV with engine-backup

 SOLUTION VERIFIED - Updated  - 

https://access.redhat.com/solutions/797463

Environment

  • Red Hat Enterprise Virtualization (RHEV) 3.3 - 3.6
  • Red Hat Virtualization (RHV) 4.0 - 4.3

Issue

  • In RHEV 3.3 and later, the backup.sh and restore.sh scripts have been deprecated. What is the new method for backing up and restoring a RHEV Manager environment?
  • How do I move RHEV Manager to another server?

Resolution

IMPORTANT: The 'engine-backup' script will not take the backup of 'rhevm-report' in rhevm 3.3. If rhevm-report is installed then upgrade to rhevm 3.4 before using this script.

Preparation

Before backing up or restoring for the first time, postgresql must have the proper access permissions, allowing local network connections to use md5 authentication. By default, this file can be found here:

/var/lib/pgsql/data/pg_hba.conf

and should contain the following additional lines for proper engine-backup functionality:

host    <database>      <user>          0.0.0.0/0               md5
host    <database>      <user>          ::0/0                   md5

Backing Up

Backing up the RHEV Manager environment can be done while the ovirt-engine service is running. The only requirement is that the output directory exist prior to invoking the command. For example, here are the steps required to backup the RHEV Manager environment into the /var/lib/ovirt-engine-backups directory:

# mkdir /var/lib/ovirt-engine-backups/
# /usr/bin/engine-backup --mode=backup --scope=all --file="/var/lib/ovirt-engine-backups/engine-backup-$(date +%Y%m%d%H%M%S).tar.bz2" --log=/var/log/ovirt-engine-backups.log
Backing up...
Done.

The above will produce a bzip2 compressed tar file with a name like /var/lib/ovirt-engine-backups/engine-backup-20140422141808.tar.bz2.

Creating an automatic cron job

  • Create a simple script called /usr/bin/backup.sh with the following contents:

    #!/bin/bash
    mkdir -p /backup
    /usr/bin/engine-backup --scope=all --mode=backup --log=/backup/backup.$(/bin/date +%Y%m%d%H%M%S).out  --file=/backup/backup.$(/bin/date +%Y%m%d%H%M%S).tar.bz2
    
  • Make /usr/bin/backup.sh executable:

    # chmod +x /usr/bin/backup.sh
    
  • Add an entry to /etc/crontab (The following example entry would cause the engine-backup script to run every night at 3:30AM):

    30 3 * * * root /usr/bin/backup.sh >/dev/null 2>&1
    

Restoring

Restoring a RHEV Manager environment using engine-backup requires the following:

  • A previously captured engine-backup backup file (see above for generating one of these)
  • An existing but empty engine database
  • If the restore will be into an already running RHEV Manager environment, ensure the ovirt-engine and ovirt-engine-dwhd services are stopped
  1. First, stop the ovirt-engine and ovirt-engine-dwhd services:

    # service ovirt-engine stop
    # service ovirt-engine-dwhd stop
    
  2. Next, ensure the engine database exists and is empty:

    • For RHEV3.4 and above:

      # su postgres -c psql
      postgres=#  DROP DATABASE engine;
      postgres=# CREATE DATABASE engine OWNER engine template template0 encoding 'UTF8' lc_collate 'en_US.UTF-8' lc_ctype 'en_US.UTF-8';
      postgres-# \q
      
    • For RHEV3.3 and earlier:

      # psql -h localhost -U postgres -W
      Password for user postgres: 
      postgres=#  DROP DATABASE engine;
      postgres=# CREATE DATABASE engine OWNER engine template template0 encoding 'UTF8' lc_collate 'en_US.UTF-8' lc_ctype 'en_US.UTF-8';
      postgres-# \q
      
  3. Restore the RHEV Manager environment:

    # /usr/bin/engine-backup --mode=restore --scope=all --file=/var/lib/ovirt-engine-backups/engine-backup-20140422141808.tar.bz2 --log=/var/log/ovirt-engine-backups.log 
    
  4. Once the DB restore is complete, the following message should be shown:

    Restoring:
    - Files
    - Engine database 'engine'
    - DWH database 'ovirt_engine_history'
    - Reports database 'ovirt_engine_reports'
    Rewriting /etc/ovirt-engine/engine.conf.d/10-setup-database.conf
    Rewriting /etc/ovirt-engine-dwh/ovirt-engine-dwhd.conf.d/10-setup-database.conf
    Rewriting /var/lib/ovirt-engine-reports/build-conf/master.properties
    You should now run engine-setup.                                <======= [As mentioned here, you should run it after doing the DB restore.]
    Done.
    
  5. After DB restore is complete, run engine-setup again:

    # engine-setup
    
  6. Finally, check and start the following services:
    # service ovirt-engine start
    # service ovirt-engine-dwhd start
    # service httpd restart

------------------------------------------------------------------------------------

How to backup and restore oVirt engine

Creating oVirt engine backups

Backup was taken in the oVirt server from command line, as shown here in our demo server. We backed up the engine database and configuration files into a single file that could be easily stored.

 

oVirt-backup

oVirt engine backup

 

The backup file was in a compressed format and could be restored easily in the future. It contained all the information to configure oVirt in case a restore was required.

RESTORE

The API script backed up these main configuration files and folders of oVirt:

'/etc/ovirt-engine/' directory that contained oVirt configuration files
'/etc/pki/ovirt-engine/' directory that contained the security files
'/var/lib/ovirt-engine/backups/' directory with the backup files
'/usr/share/ovirt-engine-reports/' directory with configuration files fore reports
'/var/log/ovirt-engine/setup/' directory for oVirt configuration settings and logs
'versionlock.list' file for versions of all oVirt cloud components

 

The database which contained the configuration settings, was also backed up by this script. The backups were then exported to our external backup server over secure channels on a daily basis.

[ Looking for the WHMCS plugin to manage your oVirt interface? Get our WHMCS plugin for oVirt management here. ]

Link to Red Hat Enterprise Virtualization 3.5 Administration Guide - Backups and Migrations.

Link to Red Hat Enterprise Virtualization 3.6 Administration Guide - Backups and Migrations.

Link to Red Hat Virtualization 4.0 Administration Guide - Backups and Migrations.

--------------------------------------------------------------------------------------

Chapter 13. Backups and Migration

13.1. Backing Up and Restoring the Red Hat Virtualization Manager

13.1.1. Backing up Red Hat Virtualization Manager - Overview

Use the engine-backup tool to take regular backups of the Red Hat Virtualization Manager. The tool backs up the engine database and configuration files into a single file and can be run without interrupting the ovirt-engine service.

13.1.2. 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. Run engine-backup --help for a full list of parameters and their function.

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 four options: all, which backs up or restores all databases and configuration data; files, which backs up or restores only files on the system; db, which backs up or restores only the Manager database; and dwhdb, which backs up or restores only the Data Warehouse database. The default scope is all.
The --scope parameter can be specified multiple times in the same engine-backup command.

Manager Database Options

The following options are only available when using the engine-backup command in restore mode. The option syntax below applies to restoring the Manager database. The same options exist for restoring the Data Warehouse database. See engine-backup --help for the Data Warehouse option syntax.
--provision-db
Creates a PostgreSQL database for the Manager database backup to be restored to. This is a required parameter when restoring a backup on a remote host or fresh installation that does not have a PostgreSQL database already configured.
--change-db-credentials
Allows you to specify alternate credentials for restoring the Manager database using credentials other than those stored in the backup itself. See engine-backup --help for the additional parameters required by this parameter.
--restore-permissions or --no-restore-permissions
Restores (or does not restore) the permissions of database users. One of these parameters is required when restoring a backup.

Note

If a backup contains grants for extra database users, restoring the backup with the --restore-permissions and --provision-db (or --provision-dwh-db) options will create the extra users with random passwords. You must change these passwords manually if the extra users require access to the restored system. See https://access.redhat.com/articles/2686731.

13.1.3. Creating a Backup with the engine-backup Command

The Red Hat Virtualization Manager can be backed up using the engine-backup command while the Manager is active. Append one of the following options to --scope to specify which backup to perform:
  • all: A full backup of all databases and configuration files on the Manager
  • files: A backup of only the files on the system
  • db: A backup of only the Manager database
  • dwhdb: A backup of only the Data Warehouse database

Important

To restore a database to a fresh installation of Red Hat Virtualization Manager, a database backup alone is not sufficient; the Manager also requires access to the configuration files. Any backup that specifies a scope other than the default, all, must be accompanied by the files scope, or a filesystem backup.

Procedure 13.1. Example Usage of the engine-backup Command

  1. Log on to the machine running the Red Hat Virtualization Manager.
  2. Create a backup:

    Example 13.1. Creating a Full Backup

    # engine-backup --scope=all --mode=backup --file=file_name --log=log_file_name

    Example 13.2. Creating a Manager Database Backup

    # engine-backup --scope=files --scope=db --mode=backup --file=file_name --log=log_file_name
    Replace the db option with dwhdb to back up the Data Warehouse database.
    tar file containing a backup is created using the path and file name provided.
The tar files containing the backups can now be used to restore the environment.

13.1.4. Restoring a Backup with the engine-backup Command

Restoring a backup using the engine-backup command involves more steps than creating a backup does, depending on the restoration destination. For example, the engine-backup command can be used to restore backups to fresh installations of Red Hat Virtualization, on top of existing installations of Red Hat Virtualization, 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 a Red Hat Virtualization version 4.0 environment can only be restored to another Red Hat Virtualization version 4.0 environment. To view the version of Red Hat Virtualization 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.

13.1.5. Restoring a Backup to a Fresh Installation

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

Procedure 13.2. Restoring a Backup to a Fresh Installation

  1. Log on to the Manager machine. If you are restoring the engine database to a remote host, you will need to log on to and perform the relevant actions on that host. Likewise, if also restoring the Data Warehouse to a remote host, you will need to log on to and perform the relevant actions on that host.
  2. Restore a complete backup or a database-only backup.
    • Restore a complete backup:
      # engine-backup --mode=restore --file=file_name --log=log_file_name --provision-db --restore-permissions
      If Data Warehouse is also being restored as part of the complete backup, provision the additional database:
      engine-backup --mode=restore --file=file_name --log=log_file_name --provision-db --provision-dwh-db --restore-permissions
    • Restore a database-only backup by restoring the configuration files and database backup:
      # engine-backup --mode=restore --scope=files --scope=db --file=file_name --log=log_file_name --provision-db --restore-permissions
      The example above restores a backup of the Manager database.
      # engine-backup --mode=restore --scope=files --scope=dwhdb --file=file_name --log=log_file_name --provision-dwh-db --restore-permissions
      The example above restores a backup of the Data Warehouse database.
    If successful, the following output displays:
    You should now run engine-setup.
    Done.
  3. Run the following command and follow the prompts to configure the restored Manager:
    # engine-setup
The Red Hat Virtualization Manager has been restored to the version preserved in the backup. To change the fully qualified domain name of the new Red Hat Virtualization system, see Section 18.1.1, “The oVirt Engine Rename Tool”.

Tidak ada komentar:

Posting Komentar