Library Version 12.1.6.0

Backing up a Replicated Application
Prev | Chapter 4. Utilities | Next

## Backing up a Replicated Application

In a stand-alone, non-replicated JE application, the log is strictly append only. You use the DbBackup class to help applications coordinate while database operations are continuing to add to the log. This helper class does this by defining the log files needed for a consistent backup, and then freezes all changes to those files, including any changes that might be made by JE background operations. The application can copy that defined set of files and finish operation without checking for the ongoing creation of new files. Also, there will be no need to check for a newer version of the last file on the next backup.

When you are using JE HA, however, log files other than the last log file might be modified as part of the HA sync-up operation. Though a rare occurrence, such modifications would invalidate the backup because there is the chance that files are modified after being copied.

If this happens, DbBackup.endBackup() throws a LogOverwriteException. Upon encountering this exception, the backup files should be discarded and a new set of backup files created.

For example:

            for (int i=0; i < BACKUP_RETRIES; i++) {
                final ReplicatedEnvironment repEnv = ...;
                final DbBackup backupHelper = new DbBackup(repEnv);

                backupHelper.startBackup();
                String[] filesForBackup =
                    backupHelper.getLogFilesInBackupSet();

                /* Copy the files to archival storage. */
                myApplicationCopyMethod(filesForBackup);

                try {
                    backupHelper.endBackup();
                    break;
                } catch (LogOverwriteException e) {
                    /* Remove backed up files. */
                    myApplicationCleanupMethod();
                    continue;
                } finally {
                    repEnv.close();
                }
            }

Prev | Up | Next
Restoring Log Files | Home | Converting Existing Environments for Replication