Recovering from media failure on the database file

The steps you need to take in the recovery process depend on whether you leave the transaction log untouched on incremental backup in your backup process. If your backup operation deletes or renames the transaction log, you may have to apply changes from several transaction logs. If your backup operation leaves the transaction log untouched, you need to use only the online transaction log in recovery.

When you have multiple transaction logs, it is possible that transactions may span transaction logs. You must apply the transaction logs in the correct order when recovering; otherwise, transactions that span multiple transaction logs are rolled back. You can specify the -ad database server option if you want the database server to determine the correct order in which to apply the transaction logs.

For more information, see Recovering from multiple transaction logs.

For more information about the backup types discussed here, see Designing backup procedures.

To recover from media failure on the database file

  1. Make an extra backup copy of the current transaction log. The database file is gone, and the only record of changes since the last backup is in the transaction log.

  2. Create a recovery directory to hold the files you use during recovery.

  3. Copy the database file from the last full backup to the recovery directory.

  4. Apply the transactions held in the backed up transaction logs to the recovery database. You can use either of the following methods to do this.

    If you want to apply each transaction log manually, for each log file, in chronological order do the following:

    1. Copy the log file into the recovery directory.
    2. Start the database server with the apply transaction log (-a) option, to apply the transaction log:
      dbeng11 database-name.db -a log-name.log

      The database server shuts down automatically once the transactions are applied.

    3. Once you have applied all of the backed up transaction logs, copy the online transaction log into the recovery directory.

      Apply the transactions from the online transaction log to the recovery database.

      dbeng11 database-name.db -a log-name.log

    If you want the database server to determine the correct order of the transaction logs and apply them automatically, do the following:

    1. Copy the offline and online transaction log files into the recovery directory.
    2. Start the database server with the -ad option, to specify the location of the transaction logs. The database server determines the correct order in which to apply the transaction logs based on the log offsets:
      dbeng11 database-name.db -ad log-directory

      The database server shuts down automatically once the transactions are applied.

  5. Perform validity checks on the recovery database.

    See Validating a database.

  6. Make a post-recovery backup.

  7. Move the database file to the production directory.

  8. Allow users to access the production database.