Recovering from a Backup
Prev | Chapter 4. Administrating Berkeley DB SQL | Next

## Recovering from a Backup

If you used standard Berkeley DB backup procedures to backup your database, then you can restore your database using the procedures described in this section.

Note that Berkeley DB supports two types of recovery:

- Normal recovery, which examines only those log records needed to bring the database to a consistent state since the last checkpoint. Normal recovery starts with any logs used by any transactions active at the time of the last checkpoint, and examines all logs from then to the current logs.

  Normal recovery is automatically run (if necessary) when you open your database. It is necessary to run recovery if a thread or process shuts down without properly closing the database.

- Catastrophic recovery examines all available log files. You use catastrophic recovery to restore your database from a previously created backup.

### Catastrophic Recovery

Use catastrophic recovery when you are recovering your database from a previously created backup. Note that to restore your database from a previous backup, you should copy the backup to a new environment directory, and then run catastrophic recovery. Failure to do so can lead to the internal database structures being out of sync with your log files.

To run catastrophic recovery:

- Shutdown all database operations.

- Restore the backup to an empty directory. This means you need your database file, as well as the `-journal` directory, and any available log files that the backup contains.

  Note that the backup database file and the journal directory must have the same name as the database and journal directory that you are restoring. You can put the backup in a different location on disk, but the name of the file and directory must remain the same.

- Make sure that a `DB_CONFIG` file exists in the journal directory that you are using to restore your database. This file must contain a the following line:

      set_data_dir ..

- Run the db_recover command line utility with the `-c` option.

Note that catastrophic recovery examines every available log file — not just those log files created since the last checkpoint as is the case for normal recovery. For this reason, catastrophic recovery is likely to take longer than does normal recovery.

Prev | Up | Next
Chapter 4. Administrating Berkeley DB SQL | Home | Syncing with Oracle Databases