Repository Management
This guide covers essential repository maintenance operations including checking repository integrity, pruning old data, and repairing issues.Overview
Proper repository maintenance ensures:- Data integrity and consistency
- Efficient storage usage
- Fast backup and restore operations
- Long-term repository health
Check Repository
Thecheck command verifies repository integrity by validating snapshots, index files, and pack files.
use rustic_core::{Repository, RepositoryOptions, CheckOptions, Credentials};
use rustic_backend::BackendOptions;
let backends = BackendOptions::default()
.repository("/path/to/repo")
.to_backends()?;
let repo = Repository::new(&RepositoryOptions::default(), &backends)?
.open(&Credentials::password("password"))?;
let opts = CheckOptions::default();
let results = repo.check(opts)?;
// Check if errors were found
results.is_ok()?;
let opts = CheckOptions::default()
.read_data(true) // Verify pack file contents
.read_data_subset(ReadSubsetOption::Percentage(10.0)); // Check 10% of data
let results = repo.check(opts)?;
Check Options
See/home/daytona/workspace/source/crates/core/src/commands/check.rs:183-203
Read Data Subsets
Time-Based Subset Checking
Prune Repository
Pruning removes unused data and optimizes repository storage.use rustic_core::PruneOptions;
let prune_opts = PruneOptions::default();
let plan = repo.prune_plan(&prune_opts)?;
// Review statistics
println!("Prune Plan Statistics:");
println!("Packs to delete: {}", plan.stats.packs_to_delete.remove);
println!("Packs to repack: {}", plan.stats.packs.repack);
println!("Packs to keep: {}", plan.stats.packs.keep);
println!("Size to delete: {} bytes", plan.stats.size_to_delete.remove);
Prune Options
See/home/daytona/workspace/source/crates/core/src/commands/prune.rs:52-134
Repack Limits
Maximum Unused Data
Pack Retention
Instant Delete
Repack Strategies
Repair Operations
Repair Index
Repair corrupted or missing index files:Repair Snapshots
Repair or delete broken snapshots:Repair Hot/Cold Repository
For hot/cold backend setups:Repository Information
Get Repository Statistics
Maintenance Best Practices
Regular Check Schedule
Prune After Forget
Always prune after deleting snapshots:Verify Before Important Operations
Monitor Repository Growth
Troubleshooting
Handle Check Failures
Recover from Corruption
See Also
- Backup Guide - Create snapshots
- Configuration - Repository settings
- CheckOptions API Reference
- PruneOptions API Reference