Skip to main content
RocksDB provides a powerful backup engine that allows you to create incremental backups and restore databases efficiently. This guide covers backup creation, verification, and restoration.

BackupEngine Overview

The BackupEngine enables:

Incremental Backups

Only new data is backed up, saving time and space.

Consistent Snapshots

Backups are consistent point-in-time snapshots.

Parallel Operations

Multiple backup operations can run concurrently.

Verification

Built-in tools to verify backup integrity.

Creating Backups

Opening a BackupEngine

Creating a New Backup

Backups are incremental by default. Only new or modified SST files are copied, making subsequent backups much faster.

Backup Options

BackupEngineOptions

CreateBackupOptions

Backup Information

Getting Backup Info

Verifying Backups

VerifyBackup() checks file existence and sizes by default. Pass true as the second argument to also verify checksums: VerifyBackup(backup_id, true)

Restoring from Backup

Basic Restore

Restore from Latest Backup

Restore Options

Managing Backups

Deleting Old Backups

Garbage Collection

GarbageCollect() will delete files from incomplete backup operations. Make sure no backup is in progress before calling this.

Complete Example

Advanced Features

Rate Limiting

Limit backup/restore I/O rate to avoid impacting production:

Custom Environment

Use a custom environment for remote backups (e.g., S3):

Metadata

Store application metadata with backups:

Backup Strategies

Take backups periodically (e.g., hourly) to minimize data loss.

Best Practices

1

Test restores regularly

Periodically test backup restoration to ensure backups are valid and complete.
2

Verify backups

Use VerifyBackup() with checksum verification enabled for critical backups.
3

Monitor backup size

Track backup sizes and growth over time to plan storage capacity.
4

Close database before restore

Always close the database before restoring from a backup.
5

Use separate backup directory

Store backups in a different location from the main database.
6

Implement retention policies

Don’t keep backups forever. Implement a policy based on your requirements.

Monitoring and Debugging

Backup Statistics

Handling Errors

Troubleshooting

  • Enable share_table_files for incremental backups
  • Increase max_background_operations
  • Use rate limiting if I/O is affecting production
  • Verify the backup first with VerifyBackup()
  • Ensure database is closed before restoring
  • Check disk space in destination directory
  • Use PurgeOldBackups() to remove old backups
  • Verify share_table_files is enabled
  • Run GarbageCollect() to clean up orphaned files

Next Steps

Configuration

Learn about backup configuration options

Performance Tuning

Optimize backup and restore performance