/** * Deletes old backups, keeping just the latest numBackupsToKeep * * @param numBackupsToKeep The latest n backups to keep * * @throws RocksDBException thrown if the old backups could not be deleted */ public void purgeOldBackups( final int numBackupsToKeep) throws RocksDBException { assert (isOwningHandle()); purgeOldBackups(nativeHandle_, numBackupsToKeep); }
/** * Backups the DB to a local path. * @param backupPath - The local backup path */ protected void backup(String backupPath) throws RocksDBException { File file = new File(backupPath); if(!file.exists()) file.mkdir(); BackupableDBOptions backupOptions = new BackupableDBOptions(backupPath) .setShareTableFiles(true) .setMaxBackgroundOperations(parallelism); BackupEngine backupEngine = BackupEngine.open(Env.getDefault(), backupOptions); backupEngine.createNewBackup(rocksDB, true); backupEngine.purgeOldBackups(backupsToKeep); backupEngine.close(); backupOptions.close(); }
delete(); backupEngine.restoreDbFromLatestBackup(dbUri.getPath(), dbUri.getPath(), restoreOptions); backupEngine.purgeOldBackups(backupsToKeep); backupEngine.close(); backupOptions.close();