Opening a BackupEngine
Open
const BackupEngineOptions&
Configuration for the backup engine including backup directory and sharing options.
Env*
Environment used by the database being backed up.
BackupEngine**
Output parameter for the opened BackupEngine.
IOStatus
Returns OK on success.
Creating Backups
CreateNewBackup
const CreateBackupOptions&
Options including whether to flush before backup and progress callback.
DB*
Database to back up.
BackupID*
Optional output parameter for the new backup’s ID.
IOStatus
Returns OK on success.
CreateNewBackupWithMetadata
Backup Management
GetBackupInfo
std::vector<BackupInfo>*
Output vector of backup information.
bool
If true, includes detailed file information for each backup.
GetLatestBackupInfo
DeleteBackup
BackupID
ID of the backup to delete.
PurgeOldBackups
GarbageCollect
Restoring Backups
RestoreDBFromBackup
const RestoreOptions&
Restore options including incremental restore mode.
BackupID
ID of the backup to restore.
const std::string&
Target directory for database files.
const std::string&
Target directory for WAL files.
IOStatus
Returns OK on success.
RestoreDBFromLatestBackup
Backup Verification
VerifyBackup
BackupID
ID of the backup to verify.
bool
If true, verifies file checksums. If false, only checks file existence and size.
Configuration
BackupEngineOptions
std::string
Directory where backups are stored. Required.
If true, table and blob files are shared among backups for space savings and incremental backups.
bool
If true, guarantees consistent backup/restore even on machine crash.
uint64_t
Max bytes per second during backup. 0 means unlimited.
int
Number of threads for parallel backup/restore operations.
CreateBackupOptions
bool
Whether to flush memtable before backup. Always triggered if 2PC is enabled.
std::function<void()>
Callback for progress reporting based on callback_trigger_interval_size.
std::function
Advanced callback to exclude shared files from backup.
RestoreOptions
Mode
Restore strategy: kKeepLatestDbSessionIdFiles (incremental), kVerifyChecksum (verify then restore), or kPurgeAllFiles (full restore).
bool
If true, don’t overwrite existing log files.
BackupInfo Structure
BackupID
Unique identifier for the backup.
int64_t
Creation time from GetCurrentTime.
uint64_t
Total size in bytes.
std::string
Application-specific metadata.
Example: Creating and Restoring Backups
File Sharing and Naming
ShareFilesNaming
ShareFilesNaming
Recommended. Uses file_number and db_session_id for unique file naming.
ShareFilesNaming
Legacy naming using CRC32c and file size. Only for preserving old behavior.