Complete Example
Step-by-Step Explanation
1. Set up logging
2. Configure the backend
3. Open and index the repository
to_indexed() method creates an index for efficient data retrieval during restore.
4. Select the snapshot to restore
- “latest”: Most recent snapshot (can also use snapshot ID or timestamp)
- Filter function:
|_| trueaccepts all snapshots; customize to filter by tags, hostname, etc.
5. List snapshot contents
6. Configure the destination
- destination: Target directory for restored files
- create: Create the destination if it doesn’t exist
- !node.is_dir(): Special handling when restoring a single file
7. Prepare the restore
- Analyzes what needs to be restored
- Creates necessary directories in the destination
- Plans the restore order for optimal performance
- dry_run: Set to
trueto see what would be restored without actually doing it
8. Execute the restore
- Downloads required data chunks from the backend
- Decrypts and decompresses data
- Writes files to the destination
- Restores file permissions and timestamps
Expected Output
During restore, you’ll see progress information:- File contents
- Directory structure
- Permissions and attributes
- Timestamps (if supported by the filesystem)
Advanced Usage
Restore specific files or directories
Filter files during restore
Select snapshot by tag or ID
Dry run to preview restore
Error Handling
Common errors and how to handle them:Related API Documentation
- RestoreOptions - Configure restore behavior
- LocalDestination - Local filesystem destination
- LsOptions - List and filter snapshot contents
- Repository::restore() - Restore operation
Next Steps
- Check repository to verify data integrity before restore
- List snapshots to find the right backup
- Learn about selective restore for advanced filtering