Backing up and Restoring MME Databases

This chapter explains how to configure QDB to back up and restore MME databases, and how to back up and restore MME databases. It includes:

Configuring the QDB for MME database backups

A database backup is a snapshot of a database, usually RAM-based, that is copied to persistent storage, such as a hard drive or a flash disk. You can use the back up to restore the database after a power cycle, or if the database becomes corrupt.

Even if you run MME databases directly from a hard drive or NAND, you may still want to perform backup and restore operations.

The MME databases are:

In order to ensure that your MME database backups are usable, you must configure the QDB correctly, and start it in the correct mode:

For more information about the QDB, see the QDB Developer's Guide.

Backing up MME databases

To back up the MME database files:

  1. Shut down the MME by calling mme_shutdown() from your client application. This step ensures that the MME does not write to its database files while the back up is underway.
  2. Back up the MME database by perform the following sequence:
    db = qdb_connect("/dev/qdb/mme", NULL);
    qdb_backup(db, QDB_ATTACH_DEFAULT);

    Note:
    • The backup command must be sent to the main MME database (typically called /dev/qdb/mme).
    • The scope argument for qdb_backup() must be set to QDB_ATTACH_DEFAULT.

Alternatively, you can start the backup from the command line using the following:

# qdbc -a default -B -d /dev/qdb/mme

Restoring MME databases

The QDB automatically restores its databases when it starts. It creates databases from one of the following sources, in the following order, as required:

The QDB configuration file qdb.cfg

The QDB configuration file qdb.cfg for the MME defines QDB behavior with MME databases. A sample configuration file is included with the MME. It is organized into configuration blocks. Each configuration block defines how the QDB behaves for the database file identified in the first line of the block.

Commented lines begin with a number sign (“#”) and are ignored by the QDB. In the configuration file delivered with the MME, the mme_custom database file and all backup directory paths are commented out.


Caution: Do not change the order of the configuration blocks or of the lines in each block. Changing their order will produce unspecified behavior.

The table below describes the options specified in the QDB configuration file for the MME. Note that many options only apply to the main MME database file mme.

Option Description
[file name] The name of the MME database file to which the options that follow apply.
Filename The path the the MME specified MME database file.
Base Schema The path to the schema file for the MME database file.
Data Schema For the mme database file only, the path to the data schema file.
Client Schema For the mme database file only, the path to the client schema file.
Backup Dir Specify at least two. The path to the directory where the QDB should write MME database backups.
Compression The type of compression to use for backups. If no compression used the QDB performs no checksums on the data copy. The lzo compression algorithm is fastest, but the bzip algorithm offers the highest compression.
Vacuum Attached If set to TRUE, include the attached database when performing vacuums.
Backup Attached If set to TRUE, include the attached database when performing backups.
Size Attached If set to TRUE, qdb_getdbsize() includes the attached database when it calculates the size of attached databases.
Auto Attach Attach the specified database when starting up. See Restoring MME databases above.

Note: The Vacuum/Backup/Size Attached options affect the database file identified by the Auto Attach that follows them. Thus, in the example configuration file provided below mme_library is vacuumed, backed up and sized, while none of these operations is performed on mme_temp.

For more detailed information about the QDB configuration file options, see The configuration file in the chapter Starting QDB of the QDB Developer's Guide.

Example qdb.cfg file

#
# QDB Database configuration file for MME
#

[mme_library]
Filename        =  /db/mme_library
Base Schema     =  /db/mme_library.sql
#Backup Dir     =  /bks1
#Backup Dir     =  /bks2
Compression     =  bzip

#[mme_custom]
#Filename       =  /db/mme_custom
#Base Schema    =  /db/mme_custom.sql
##Backup Dir    =  /bks1
##Backup Dir    =  /bks2
#Compression    =  bzip

[mme_temp]
Filename        =  /fs/tmpfs/mme_temp.db
Schema File     =  /db/mme_temp.sql

[mme]
Filename        =  /db/mme
Base Schema     =  /db/mme.sql
Data Schema     =  /db/mme_data.sql
Client Schema   =  /db/mme_connect.sql
#Backup Dir     =  /bks1
#Backup Dir     =  /bks2
Compression     =  bzip
Vacuum Attached =  TRUE
Backup Attached =  TRUE
Size Attached   =  TRUE
Auto Attach     =  mme_library
#Auto Attach    =  mme_custom
Vacuum Attached =  FALSE
Backup Attached =  FALSE
Size Attached   =  FALSE
Auto Attach     =  mme_temp