Backing up and restoring the OpenStack databases
The backup procedure is different depending on the database that is being used.
Backing up database data for recovery
All of the database data that is related to IBM® Cloud Manager with OpenStack users, such as projects, networks, instances, images, are stored in the database. The backup procedure is different depending on the database that is being used.
- Stop the IBM Cloud Manager with OpenStack services to ensure that the backup data is complete.
- Follow the instructions that pertain to your specific database.
- MariaDB or MySQL
- For more information, see Backup and Recovery in the OpenStack community documentation.
- DB2® OpenStack database
- DB2 can also be used to
host the OpenStack databases
on the cloud controller. The following shell script backs up a list
of DB2 OpenStack databases.
This shell script must be modified to match the environment. The variable DB is
where the DB2 program is located.
The variable DBLIST is a list of OpenStack databases
to back up. The variable DBBACKUPDIR is a directory
to save the backups in. Since this shell script quiesces each database,
while this shell script runs, calls to these databases fail. The backup
directory contains the backup files that appear similar to the following
example: NOVA.0.db2inst1.DBPART000.20140523134214.001 The
following shell script is an example DB2 OpenStack database
backup script:
#!/bin/bash ########################################################## # DB2 OpenStack DB backup Linux shell script # MODIFY these variables to fit your environment # DB2 - home directory of DB2 # DBLIST - list of Openstack DB to be backed up # DBBACKUPDIR - directory holding backed up copies ########################################################## DB2="/opt/ibm/db2/V10.5/bin/db2" DBLIST="nova glance" DBBACKUPDIR="/tmp/DB2backupOpenstack" mkdir -p $DBBACKUPDIR for DB in $DBLIST do su - db2inst1 <<EOSU echo "------DB $DB is being backed up ------" $DB2 connect to $DB $DB2 quiesce database immediate force connections $DB2 connect reset echo $DB2 backup database $DB to $DBBACKUPDIR without prompting $DB2 backup database $DB to $DBBACKUPDIR without prompting $DB2 connect to $DB $DB2 unquiesce database $DB2 connect reset EOSU doneFor more information, see Backup and Recovery in the OpenStack community documentation.
For more information about how to back up the DB2 server, see the DB2 product information.Notes:- Default database names are: nova horizon glance neutron
keystone ceilodb2 heat cinder ironic sspdb. To list the OpenStack DB names,
log on to the DB2 server,
and show databases with the db2 command:
$ db2 list db directory | grep "Database name" Database name = IRONIC Database name = SSPDB Database name = NOVA Database name = GLANCE Database name = KEYSTONE Database name = HORIZON Database name = NEUTRON Database name = CINDER Database name = HEAT Database name = CEILODB2 - Ensure that the information referenced matches the version of DB2 that you are using. If not, reference the appropriate support documentation for similar information.
- Default database names are: nova horizon glance neutron
keystone ceilodb2 heat cinder ironic sspdb. To list the OpenStack DB names,
log on to the DB2 server,
and show databases with the db2 command:
Using an online backup for the DB2 OpenStack databases
The
default backup is an offline backup. Online backups are available
only for databases that are configured with logarchmeth1 enabled.
Online backups require that the database be enabled for rollforward
recovery. To configure rollforward recovery, you must set the LOGARCHMETH1 database
configuration parameter.
Note: When you have set the LOGARCHMETH1 database
configuration parameter, you must run one offline backup. When you
have completed these steps, you can run online backups as needed.
For more information, see BACKUP DATABASE command.
The
following steps show an example for the nova database online backup.
Refer to your databases list, and back up each database, one at a
time.
- To check if the database is configured with logarchmeth1 enabled,
run the following command:
#db2 get db cfg for nova | grep LOGARCH First log archive method (LOGARCHMETH1) = OFF Archive compression for logarchmeth1 (LOGARCHCOMPR1) = OFF Options for logarchmeth1 (LOGARCHOPT1) = Second log archive method (LOGARCHMETH2) = OFF Archive compression for logarchmeth2 (LOGARCHCOMPR2) = OFF Options for logarchmeth2In the output, the value logarchmeth1 is in off mode, which implies that the current database is in CIRCULAR LOGGING mode. If you need to work with ARCHIVE LOGGING mode, you must change or add the path in the variables that logarchmeth1 present in the configuration file.
- Update logarchmeth1 with the required archive
directory.
$mkdir /tmp/DB2OnlinebackupOpenstack $ db2 update database configuration for nova using LOGARCHMETH1 'DISK:/tmp/DB2OnlinebackupOpenstack' DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. - Start the online backup.
$db2 backup database nova online to /home/db2inst1/DB2OnlinebackupOpenstack/ compress include logs
Restoring the DB2 OpenStack databases
DB2 can also be used to host the OpenStack databases
on the cloud controller. The following shell script can restore a DB2 OpenStack database.
This shell script must be modified to match the environment. The variable DB2 is
where the DB2 program is located.
The variable DBBACKUPDIR is a directory where the
backup files are located. The Variable DB is the OpenStack database
to restore. The variable DBBACKUPTIME is the time
stamp part of the backup file name, found in the backup directory.
Since this shell script quiesces each database, while this shell script
runs, calls to these databases fail. Here is an example DB2 OpenStack database
restore shell script:
#!/bin/bash
##########################################################
# DB2 OpenStack DB restore Linux shell script
# MODIFY these variables to fit your environment
# DB2HOME - home directory of DB2
# DB - database name to be restored
# DBBACKUPDIR - directory holding backed up copies
# DBBACKUPTIME - timestamp part of backupname
# example : 20140522162140
##########################################################
DB2="/opt/ibm/db2/V10.5/bin/db2"
DBBACKUPDIR="/tmp/DB2backupOpenstack"
DB="nova"
DBBACKUPTIME="20140523135648"
su - db2inst1 <<EOSU
$DB2 connect to $DB
$DB2 quiesce database immediate force connections
$DB2 connect reset
echo $DB2 restore database $DB from $DBBACKUPDIR taken at $DBBACKUPTIME without prompting
$DB2 restore database $DB from $DBBACKUPDIR taken at $DBBACKUPTIME without prompting
$DB2 connect to $DB
$DB2 unquiesce database
$DB2 connect reset
EOSUFor more information, see Backup and Recovery in the OpenStack community
documentation.