BDBBackup is a utility for taking hot backups of the current state of a BDB transaction log database.
This utility makes the following assumptions/performs the following actions:
- The from and to directory locations will already exist. This scripts does not create them.
- If this script fails to complete in one minute it will terminate.
- This script always exits with code 1 on error, code 0 on success (standard unix convention).
- This script will log out at info level, when it starts and ends and a list of all files backed up.
- This script logs all errors at error level.
- This script does not perform regular backups, wrap its calling script in a cron job or similar to do this.
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 {@link #takeBackup(String,String,com.sleepycat.je.Environment)} method.
A seperate backup machanism is provided by the {@link #takeBackupNoLock(String,String)} method which can take ahot 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 {@link #main} method of this utilityuses.
| /**
* Supplies a triggered action extension, based on message count. This action takes a BDB log file backup.
*/
public void takeAction()
{
BDBBackup backupUtil = new BDBBackup();
backupUtil.takeBackupNoLock(fromDir, toDir);
System.out.println("Took backup of BDB log files from directory: " + fromDir);
}
|
Related Classes of org.apache.qpid.server.store.berkeleydb.BDBBackup
Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact
coftware#gmail.com.