-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #708 from rustic-rs/prune-example
prune: Add example using rustic_core
- Loading branch information
Showing
2 changed files
with
63 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! `prune` example | ||
use rustic_core::{PruneOpts, Repository, RepositoryOptions}; | ||
use simplelog::{Config, LevelFilter, SimpleLogger}; | ||
|
||
fn main() { | ||
// Display info logs | ||
let _ = SimpleLogger::init(LevelFilter::Info, Config::default()); | ||
|
||
// Open repository | ||
let mut repo_opts = RepositoryOptions::default(); | ||
repo_opts.repository = Some("/tmp/repo".to_string()); | ||
repo_opts.password = Some("test".to_string()); | ||
let repo = Repository::new(&repo_opts).unwrap().open().unwrap(); | ||
|
||
let prune_opts = PruneOpts::default(); | ||
let prune_plan = repo.prune_plan(&prune_opts).unwrap(); | ||
println!("{:?}", prune_plan.stats); | ||
println!("to repack: {:?}", prune_plan.repack_packs()); | ||
// to run the plan uncomment this line: | ||
// prune_plan.do_prune(&repo, &prune_opts).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters