public class RestoreBackupableDB extends RocksObject
This class is used to access information about backups and restore from them.
Note: dispose()
must be called before this instance
become out-of-scope to release the allocated
memory in c++.
nativeHandle_
Constructor and Description |
---|
RestoreBackupableDB(BackupableDBOptions options)
Construct new estoreBackupableDB instance.
|
Modifier and Type | Method and Description |
---|---|
void |
deleteBackup(int backupId)
Deletes a specific backup.
|
void |
disposeInternal()
Release the memory allocated for the current instance
in the c++ side.
|
void |
garbageCollect()
Will delete all the files we don't need anymore.
|
java.util.List<BackupInfo> |
getBackupInfos()
Returns a list of
BackupInfo instances, which describe
already made backups. |
int[] |
getCorruptedBackups()
Returns a list of corrupted backup ids.
|
void |
purgeOldBackups(int numBackupsToKeep)
Deletes old backups, keeping latest numBackupsToKeep alive.
|
void |
restoreDBFromBackup(long backupId,
java.lang.String dbDir,
java.lang.String walDir,
RestoreOptions restoreOptions)
Restore from backup with backup_id.
|
void |
restoreDBFromLatestBackup(java.lang.String dbDir,
java.lang.String walDir,
RestoreOptions restoreOptions)
Restore from the latest backup.
|
disOwnNativeHandle, dispose, finalize, isInitialized, isOwningNativeHandle
public RestoreBackupableDB(BackupableDBOptions options)
Construct new estoreBackupableDB instance.
options
- BackupableDBOptions
instancepublic void restoreDBFromBackup(long backupId, java.lang.String dbDir, java.lang.String walDir, RestoreOptions restoreOptions) throws RocksDBException
Restore from backup with backup_id.
Important: If options_.share_table_files == true and you restore 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. If you add new data to the DB and try creating a new backup now, the database will diverge from backups 4 and 5 and the new backup will fail. If you want to create new backup, you will first have to delete backups 4 and 5.
backupId
- id pointing to backupdbDir
- database directory to restore towalDir
- directory where wal files are locatedrestoreOptions
- RestoreOptions
instance.RocksDBException
- thrown if error happens in underlying
native library.public void restoreDBFromLatestBackup(java.lang.String dbDir, java.lang.String walDir, RestoreOptions restoreOptions) throws RocksDBException
Restore from the latest backup.
dbDir
- database directory to restore towalDir
- directory where wal files are locatedrestoreOptions
- RestoreOptions
instanceRocksDBException
- thrown if error happens in underlying
native library.public void purgeOldBackups(int numBackupsToKeep) throws RocksDBException
Deletes old backups, keeping latest numBackupsToKeep alive.
numBackupsToKeep
- of latest backups to keepRocksDBException
- thrown if error happens in underlying
native library.public void deleteBackup(int backupId) throws RocksDBException
Deletes a specific backup.
backupId
- of backup to delete.RocksDBException
- thrown if error happens in underlying
native library.public java.util.List<BackupInfo> getBackupInfos()
Returns a list of BackupInfo
instances, which describe
already made backups.
BackupInfo
instances.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 disposeInternal()
Release the memory allocated for the current instance in the c++ side.
disposeInternal
in class RocksObject