Performing Backups
Prev | Chapter 8. Backing up and Restoring Berkeley DB Java Edition Applications | Next

## Performing Backups

This section describes how to backup your JE database(s) such that catastrophic recovery is possible.

To backup your database, you can either take a complete backup or a partial backup. A partial backup is performed while database write operations are in progress.

Do not confuse complete and partial backups with the concept of a full and incremental backup. Both a complete and a partial backup are full backups – you back up the entire database. The only difference between them is how much of the contents of the in-memory cache are contained in them. On the other hand, an incremental backup is a backup of just those log files modified or created since the time of the last backup. Most backup software is capable of performing both full and incremental backups for you.

### Performing a Partial Backup

To perform a partial backup of your JE databases, copy all log files (`*.jdb` files) from your environment directory to your archival location or backup media. The files must be copied n alphabetical order (numerical in effect). You do not have to stop any database operations in order to do this.

Note that if your application is not using transactions, then any modifications made to the database since the time of the last environment sync are not guaranteed to be contained in these log files. In this case, you may want to consider running a complete backup in order to guarantee the availability of all modifications made to your database.

### Performing a Complete Backup

A complete backup guarantees that you have captured the database in its entirety, including all contents of your in-memory cache, at the moment that the backup was taken. To do this, you must make sure that no write operations are in progress and all database modifications have been written to your log files on disk. To obtain a complete backup:

1. Stop writing your databases. If you are using transactions, commit or abort all on-going transactions.

2. If you are not using transactions, run `Environment.sync()` so as to ensure that all database modifications are written to disk.

3. If you are using transactions, then optionally run a checkpoint. Doing this can shorten the time required to restore your database from this back up.

4. Copy all log files (`*.jdb`) from your environment directory to your archival location or backup media.

You can now resume normal database operations.

Prev | Up | Next
Chapter 8. Backing up and Restoring Berkeley DB Java Edition Applications | Home | Performing Catastrophic Recovery