Backup and Restore¶
BackupEngine¶
-
class
rocksdb.
BackupEngine
¶ -
__init__
(backup_dir)¶ Creates a object to manage backup of a single database.
Parameters: backup_dir (unicode) – Where to keep the backup files. Has to be different than db.db_name. For example db.db_name + ‘/backups’.
-
create_backup
(db, flush_before_backup=False)¶ Triggers the creation of a backup.
Parameters: - db (
rocksdb.DB
) – Database object to backup. - flush_before_backup (bool) – If
True
the current memtable is flushed.
- db (
-
restore_backup
(backup_id, db_dir, wal_dir)¶ Restores the backup from the given id.
Parameters: - backup_id (int) – id of the backup to restore.
- db_dir (unicode) – Target directory to restore backup.
- wal_dir (unicode) – Target directory to restore backuped WAL files.
-
restore_latest_backup
(db_dir, wal_dir)¶ Restores the latest backup.
Parameters: - db_dir (unicode) – see
restore_backup()
- wal_dir (unicode) – see
restore_backup()
- db_dir (unicode) – see
-
stop_backup
()¶ Can be called from another thread to stop the current backup process.
-
purge_old_backups
(num_backups_to_keep)¶ Deletes all backups (oldest first) until “num_backups_to_keep” are left.
Parameters: num_backups_to_keep (int) – Number of backupfiles to keep.
-
delete_backup
(backup_id)¶ Parameters: backup_id (int) – Delete the backup with the given id.
-
get_backup_info
()¶ Returns information about all backups.
It returns a list of dict’s where each dict as the following keys.
backup_id
- (int): id of this backup.
timestamp
- (int): Seconds since epoch, when the backup was created.
size
- (int): Size in bytes of the backup.
-