Skip to content

Commit

Permalink
Merge pull request #712 from rustic-rs/refactor-forget
Browse files Browse the repository at this point in the history
move forget to rustic_core
  • Loading branch information
aawsome committed Jun 26, 2023
2 parents 5c7d18c + 0f553b5 commit 375585a
Show file tree
Hide file tree
Showing 7 changed files with 508 additions and 337 deletions.
26 changes: 26 additions & 0 deletions crates/rustic_core/examples/forget.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//! `forget` example
use rustic_core::{KeepOptions, Repository, RepositoryOptions, SnapshotGroupCriterion};
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();

// Check respository with standard options
let group_by = SnapshotGroupCriterion::default();
let mut keep = KeepOptions::default();
keep.keep_daily = 5;
keep.keep_weekly = 10;
let snaps = repo
.get_forget_snapshots(&keep, group_by, |_| true)
.unwrap();
println!("{snaps:?}");
// to remove the snapshots-to-forget, uncomment this line:
// repo.delete_snapshots(&snaps.into_forget_ids()).unwrap()
}
1 change: 1 addition & 0 deletions crates/rustic_core/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod cat;
pub mod check;
pub mod forget;
pub mod prune;
pub mod repoinfo;
pub mod snapshots;
Loading

0 comments on commit 375585a

Please sign in to comment.