public class BDBBackup extends Object
This utility makes the following assumptions/performs the following actions:
This utility is build around the BDB provided backup helper utility class, DbBackup. This utility class provides an ability to force BDB to stop writing to the current log file set, whilst the backup is taken, to ensure that a consistent snapshot is acquired. Preventing BDB from writing to the current log file set, does not stop BDB from continuing to run concurrently while the backup is running, it simply moves onto a new set of log files; this provides a 'hot' backup facility.
DbBackup can also help with incremental backups, by providing the number of the last log file backed up. Subsequent backups can be taken, from later log files only. In a messaging application, messages are not expected to be long-lived in most cases, so the log files will usually have been completely turned over between backups. This utility does not support incremental backups for this reason.
If the database is locked by BDB, as is required when using transactions, and therefore will always be the case
in Qpid, this utility cannot make use of the DbBackup utility in a seperate process. DbBackup, needs to ensure that
the BDB envinronment used to take the backup has exclusive write access to the log files. This utility can take a
backup as a standalone utility against log files, when a broker is not running, using the takeBackup(String,
String,com.sleepycat.je.Environment)
method.
A separate backup machanism is provided by the takeBackupNoLock(String,String)
method which can take a
hot backup against a running broker. This works by finding out the set of files to copy, and then opening them all to
read, and repeating this process until a consistent set of open files is obtained. This is done to avoid the
situation where the BDB cleanup thread deletes a file, between the directory listing and opening of the file to copy.
All consistently opened files are copied. This is the default mechanism the the main(java.lang.String[])
method of this utility
uses.
Modifier and Type | Field and Description |
---|---|
static String[][] |
COMMAND_LINE_SPEC
Defines the command line format for this utility.
|
static long |
TIMEOUT
Defines the timeout to terminate the backup operation on if it fails to complete.
|
Constructor and Description |
---|
BDBBackup() |
Modifier and Type | Method and Description |
---|---|
static void |
main(String[] args)
Runs a backup of the BDB log files in a specified directory, copying the backed up files to another specified
directory.
|
void |
takeBackup(String fromdir,
String todir,
com.sleepycat.je.Environment environment)
Creates a backup of the BDB log files in the source directory, copying them to the destination directory.
|
String[] |
takeBackupNoLock(String fromdir,
String todir)
Takes a hot backup when another process has locked the BDB database.
|
public static final String[][] COMMAND_LINE_SPEC
public static final long TIMEOUT
public static void main(String[] args)
The following arguments must be specified:
Option | Comment |
---|---|
-fromdir | The path to the directory to back the bdb log file from. |
-todir | The path to the directory to save the backed up bdb log files to. |
args
- The command line arguments.public void takeBackup(String fromdir, String todir, com.sleepycat.je.Environment environment) throws com.sleepycat.je.DatabaseException
fromdir
- The source directory path.todir
- The destination directory path.environment
- An open BDB environment to perform the back up.com.sleepycat.je.DatabaseException
- Any underlying execeptions from BDB are allowed to fall through.public String[] takeBackupNoLock(String fromdir, String todir)
fromdir
- The source directory path.todir
- The destination directory path.Copyright © 2006–2016 The Apache Software Foundation. All rights reserved.