public class BackupEngine extends RocksObject implements java.lang.AutoCloseable
nativeHandle_| Modifier | Constructor and Description |
|---|---|
protected |
BackupEngine() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the Backup Engine
|
void |
createNewBackup(RocksDB db)
Captures the state of the database in the latest backup
Just a convenience for
createNewBackup(RocksDB, boolean) with
the flushBeforeBackup parameter set to false |
void |
createNewBackup(RocksDB db,
boolean flushBeforeBackup)
Captures the state of the database in the latest backup
|
void |
deleteBackup(int backupId)
Deletes a backup
|
protected void |
disposeInternal()
The helper function of
dispose() which all subclasses of
RocksObject must implement to release their associated
C++ resource. |
void |
garbageCollect()
Will delete all the files we don't need anymore.
|
java.util.List<BackupInfo> |
getBackupInfo()
Gets information about the available
backups
|
int[] |
getCorruptedBackups()
Returns a list of corrupted backup ids.
|
static BackupEngine |
open(Env env,
BackupableDBOptions options)
Opens a new Backup Engine
|
void |
purgeOldBackups(int numBackupsToKeep)
Deletes old backups, keeping just the latest numBackupsToKeep
|
void |
restoreDbFromBackup(int backupId,
java.lang.String dbDir,
java.lang.String walDir,
RestoreOptions restoreOptions)
Restore the database from a backup
IMPORTANT: if options.share_table_files == true and you restore the DB
from some backup that is not the latest, and you start creating new
backups from the new DB, they will probably fail!
Example: Let's say you have backups 1, 2, 3, 4, 5 and you restore 3.
|
void |
restoreDbFromLatestBackup(java.lang.String dbDir,
java.lang.String walDir,
RestoreOptions restoreOptions)
Restore the database from the latest backup
|
disOwnNativeHandle, dispose, finalize, isInitialized, isOwningNativeHandlepublic static BackupEngine open(Env env, BackupableDBOptions options) throws RocksDBException
env - The environment that the backup engine should operate withinoptions - Any options for the backup engineRocksDBExceptionpublic void createNewBackup(RocksDB db) throws RocksDBException
createNewBackup(RocksDB, boolean) with
the flushBeforeBackup parameter set to falsedb - The database to backup
Note - This method is not thread safeRocksDBExceptionpublic void createNewBackup(RocksDB db, boolean flushBeforeBackup) throws RocksDBException
db - The database to backupflushBeforeBackup - When true, the Backup Engine will first issue a
memtable flush and only then copy the DB files to
the backup directory. Doing so will prevent log
files from being copied to the backup directory
(since flush will delete them).
When false, the Backup Engine will not issue a
flush before starting the backup. In that case,
the backup will also include log files
corresponding to live memtables. The backup will
always be consistent with the current state of the
database regardless of the flushBeforeBackup
parameter.
Note - This method is not thread safeRocksDBExceptionpublic java.util.List<BackupInfo> getBackupInfo()
public int[] getCorruptedBackups()
Returns a list of corrupted backup ids. If there is no corrupted backup the method will return an empty list.
public void garbageCollect()
throws RocksDBException
Will delete all the files we don't need anymore. It will do the full scan of the files/ directory and delete all the files that are not referenced.
RocksDBException - thrown if error happens in underlying
native library.public void purgeOldBackups(int numBackupsToKeep)
throws RocksDBException
numBackupsToKeep - The latest n backups to keepRocksDBExceptionpublic void deleteBackup(int backupId)
throws RocksDBException
backupId - The id of the backup to deleteRocksDBExceptionpublic void restoreDbFromBackup(int backupId,
java.lang.String dbDir,
java.lang.String walDir,
RestoreOptions restoreOptions)
throws RocksDBException
backupId - The id of the backup to restoredbDir - The directory to restore the backup to, i.e. where your
database iswalDir - The location of the log files for your database,
often the same as dbDirrestoreOptions - Options for controlling the restoreRocksDBExceptionpublic void restoreDbFromLatestBackup(java.lang.String dbDir,
java.lang.String walDir,
RestoreOptions restoreOptions)
throws RocksDBException
dbDir - The directory to restore the backup to, i.e. where your database iswalDir - The location of the log files for your database, often the same as dbDirrestoreOptions - Options for controlling the restoreRocksDBExceptionpublic void close()
throws RocksDBException
close in interface java.lang.AutoCloseableRocksDBExceptionprotected void disposeInternal()
RocksObjectdispose() which all subclasses of
RocksObject must implement to release their associated
C++ resource.disposeInternal in class RocksObject