Backup and Restore¶
- class rocksdb.BackupEngine¶
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.
- db (rocksdb.DB) – Database object to backup.
- flush_before_backup (bool) – If True the current memtable is flushed.
- restore_backup(backup_id, db_dir, wal_dir)¶
Restores the backup from the given id.
- 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.
- db_dir (unicode) – see restore_backup()
- wal_dir (unicode) – see restore_backup()
Can be called from another thread to stop the current backup process.
Deletes all backups (oldest first) until “num_backups_to_keep” are left.
Parameters: num_backups_to_keep (int) – Number of backupfiles to keep.
Parameters: backup_id (int) – Delete the backup with the given id.
Returns information about all backups.
It returns a list of dict’s where each dict as the following keys.
- (int): id of this backup.
- (int): Seconds since epoch, when the backup was created.
- (int): Size in bytes of the backup.