Skip to content

Backups with BabuDB

lkairies edited this page Jun 12, 2014 · 1 revision

Performing a backup in BabuDB is a two step procedure. First, a snapshot is created for each database including all indices. Second, this snapshot is written out to disk at a given location. The consistency of the backup is therefore reflected by the state of the database at the time of the snapshot. Backups are done using the dumpAllDatabases(String destinationPath)-method within the DatabaseManager.

Note that the snapshots are only per-database. This means that if BabuDB has many databases a backup is not exactly at the same point in time for all databases.

Example code

String dbDir = "/tmp/babudb/";
String backupDir = "/tmp/babudb-backup/";

BabuDB database = (BabuDB) BabuDBFactory.createBabuDB(
   new BabuDBConfig(dbDir, dbDir, 1, 0, 0, SyncMode.SYNC_WRITE, 0, 0, false, 128, 1024*1024*512),null);
        
Database db = database.getDatabaseManager().createDatabase("test", numIndices);
        
System.out.println("Creating backup database...");
database.getDatabaseManager().dumpAllDatabases(backupDir);

A backup can be recovered by opening the backup directory. A backup doesn't contain any log-files since there where no changes after the snapshot. If BabuDB is using a separate log-file directory, this must be configured via BabuDBConfig. It is recommended to have an empty directory for the log-files when recovering a backed up BabuDB. Example of recovering the backed-up database:

BabuDB database = (BabuDB) BabuDBFactory.createBabuDB(
   new BabuDBConfig(backupDir, backupDir, 1, 0, 0, SyncMode.SYNC_WRITE, 0, 0, false, 128, 1024*1024*512),null);
Clone this wiki locally