diff --git a/docs/administration-guide.rst b/docs/administration-guide.rst index 23072b90..9c596f34 100644 --- a/docs/administration-guide.rst +++ b/docs/administration-guide.rst @@ -471,6 +471,8 @@ on that. .. code-block:: console # proxmox-backup-client prune host/elsa --dry-run --keep-daily 1 --keep-weekly 3 + retention options: --keep-daily 1 --keep-weekly 3 + Testing prune on store "store2" group "host/elsa" host/elsa/2019-12-04T13:20:37Z keep host/elsa/2019-12-03T09:35:01Z remove host/elsa/2019-11-22T11:54:47Z keep diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 3869a177..edaf2839 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -339,6 +339,7 @@ fn prune( worker.log("No prune selection - keeping all files."); return Ok(()); } else { + worker.log(format!("retention options: {}", prune_options.cli_options_string())); if dry_run { worker.log(format!("Testing prune on store \"{}\" group \"{}/{}\"", store, backup_type, backup_id)); diff --git a/src/backup/prune.rs b/src/backup/prune.rs index e55486dc..eb03891a 100644 --- a/src/backup/prune.rs +++ b/src/backup/prune.rs @@ -131,6 +131,43 @@ impl PruneOptions { if let Some(count) = self.keep_yearly { if count > 0 { keep_something = true; } } keep_something } + + pub fn cli_options_string(&self) -> String { + let mut opts = Vec::new(); + + if let Some(count) = self.keep_last { + if count > 0 { + opts.push(format!("--keep-last {}", count)); + } + } + if let Some(count) = self.keep_hourly { + if count > 0 { + opts.push(format!("--keep-hourly {}", count)); + } + } + if let Some(count) = self.keep_daily { + if count > 0 { + opts.push(format!("--keep-daily {}", count)); + } + } + if let Some(count) = self.keep_weekly { + if count > 0 { + opts.push(format!("--keep-weekly {}", count)); + } + } + if let Some(count) = self.keep_monthly { + if count > 0 { + opts.push(format!("--keep-monthly {}", count)); + } + } + if let Some(count) = self.keep_yearly { + if count > 0 { + opts.push(format!("--keep-yearly {}", count)); + } + } + + opts.join(" ") + } } pub fn compute_prune_info(