Recover consolidated databases automatically

The following procedure describes how to automatically recover a consolidated database. To apply the transaction logs manually, see Recover consolidated databases manually.

To recover the database using the -ad option
  1. Make a copy of the database and transaction log file. This procedure assumes that previous backups of the database file have been made and are available, for example on tape.

  2. Restore the most recent backed up copy of the database (.db) file, not the transaction log file, from tape into a temporary directory.

  3. In the temporary directory:

    1. Start the database, applying the transaction logs using the -ad option.

      When you specify the -ad option, the database server looks in the specified directory for the transaction logs for the database. It then determines the correct order to apply the logs based on the transaction log offsets.

    2. Copy the current transaction log, to the temporary directory.

    3. Start the database and apply the current transaction log.

    4. Shut down the database server.

    5. Back up the database and transaction log.

  4. Copy database and transaction log files to the appropriate production directories.

  5. Restart your system as normal.

    Any new activity is appended to the current transaction log.

Example

Suppose you have a consolidated database file named c:\dbdir\cons.db, a transaction log file c:\dbdir\cons.log, and a transaction log mirror file d:\mirdir\cons.mlg.

Assume that you perform full backups weekly using the following command:

dbbackup -c "UID=DBA;PWD=sql" -r -n e:\backdir

Assume that you also perform incremental backups daily using the following command:

dbbackup -c "UID=DBA;PWD=sql" -r -n -t e:\backdir

This command backs up the transaction log cons.log to the directory e:\backdir. The transaction log file is then renamed to datexx.log, where date is the current date and xx is the next set of letters in sequence, and a new transaction log is started. The directory e:\backdir is then backed up using a third-party utility.

In this scenario, you would run the Message Agent (dbremote) with the optional directory to point to the renamed transaction log files. For example:

dbremote -c "UID=DBA;PWD=sql" c:\dbdir

On the third day following the weekly backup, the database file is corrupted because of a bad disk block.

To recover from media failure on the c drive
  1. Replace the c:\ drive.

  2. Back up the transaction log mirror file d:\mirdir\cons.mlg.

  3. Create a temporary directory to perform the recovery in. In this example, it is called c:\recover.

  4. Restore the most recent backup of the database file, cons.db to c:\recover\cons.db.

  5. Copy the backed up transaction logs to c:\dbdir.

  6. Apply the renamed transaction logs:

    dbeng11 c:\recover\cons.db -ad c:\dbdir
  7. Copy the current transaction log, d:\mirdir\cons.log to the recovery directory, giving c:\recover\cons.log.

  8. Start the database using the following command:

    dbeng11 c:\recover\cons.db
  9. Shut down the database server.

  10. Back up the recovered database and transaction log from c:\recover.

  11. Copy the files from c:\recover to the appropriate production directories:

    • Copy c:\recover\cons.db to c:\dbdir\cons.db.

    • Copy c:\recover\cons.log to c:\dbdir\cons.log, and to d:\mirdir\cons.mlg.

  12. Restart your system as normal.

See also