Complete Example
Step-by-Step Explanation
1. Set up logging
2. Configure backends with hot storage
- repository: Main backend for all data
- repo_hot: Optional fast storage for recent snapshots and metadata
3. Open the repository
to_indexed_ids() call is crucial for efficient deduplication during backup.
4. Configure backup options
- backup_opts: Controls behavior like compression, parallelism, and excludes
- source: Paths to backup (in this case, current directory)
- sanitize(): Normalizes and validates paths
5. Set snapshot metadata
- Tags: Labels for organizing and filtering snapshots
- Hostname: Automatically detected or can be set manually
- Time: Defaults to current time
6. Create the backup
- Scan the source files and directories
- Detect changes since the last snapshot
- Deduplicate data by splitting into chunks
- Encrypt and compress chunks
- Upload new data to the backend
- Create the snapshot metadata
7. Display results
Expected Output
During backup, you’ll see progress information:- Files categorized as new, changed, or unmodified
- Amount of new data added to the repository
- Total files and directories processed
- Deduplication ratio and compression statistics
Advanced Configuration
Exclude patterns
Custom parent snapshot
Related API Documentation
- BackupOptions - Configure backup behavior
- SnapshotOptions - Set snapshot metadata
- PathList - Specify backup sources
- Repository::backup() - Backup operation
Next Steps
- Restore a snapshot to recover backed up data
- List snapshots to browse backups
- Check repository to verify backup integrity