### Berkeley DB Reference Guide: Access Method Operations |

# Upgrading databases

When upgrading to a new release of Berkeley DB, it may be necessary to upgrade the on-disk format of already-created database files.

It is important to realize that Berkeley DB database upgrades are done in place, and so are potentially destructive. This means that if the system crashes during the upgrade procedure, or if the upgrade procedure runs out of disk space, the databases may be left in an inconsistent and unrecoverable state.

To guard against failure, the following procedure should be followed:

1. Cleanly shutdown database operations.

   To cleanly shutdown database operations, all applications accessing the database environment must be shutdown and a transaction checkpoint must be taken. If the applications are not implemented such that they can be shutdown gracefully (i.e., closing all references to the database environment), recovery must be performed after all applications have been killed to ensure that the underlying databases are consistent on disk.

2. Archive the database for catastrophic recovery. See Archival procedures for more information.

3. Upgrade the database using the DB->upgrade function. If this call fails for any reason, use the catastrophic recovery archive to restore the database.

4. Restart database applications.

Copyright Sleepycat Software