diff options
Diffstat (limited to 'src/cmd/backup.rs')
-rw-r--r-- | src/cmd/backup.rs | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/src/cmd/backup.rs b/src/cmd/backup.rs index 8a85703..60045cc 100644 --- a/src/cmd/backup.rs +++ b/src/cmd/backup.rs @@ -19,7 +19,11 @@ use tokio::runtime::Runtime; /// Make a backup. #[derive(Debug, StructOpt)] pub struct Backup { - /// Backup schema major version. + /// Force a full backup, instead of an incremental one. + #[structopt(long)] + full: bool, + + /// Backup schema major version to use. #[structopt(long)] backup_version: Option<VersionComponent>, } @@ -53,29 +57,35 @@ impl Backup { let oldtemp = temp.path().join("old.db"); let newtemp = temp.path().join("new.db"); - let (is_incremental, outcome) = match genlist.resolve("latest") { - Err(_) => { - info!("fresh backup without a previous generation"); - let mut run = BackupRun::initial(config, &client)?; - let old = run.start(None, &oldtemp, perf).await?; - ( - false, - run.backup_roots(config, &old, &newtemp, schema, perf) - .await?, - ) - } - Ok(old_id) => { - info!("incremental backup based on {}", old_id); - let mut run = BackupRun::incremental(config, &client)?; - let old = run.start(Some(&old_id), &oldtemp, perf).await?; - ( - true, - run.backup_roots(config, &old, &newtemp, schema, perf) - .await?, - ) + let old_id = if self.full { + None + } else { + match genlist.resolve("latest") { + Err(_) => None, + Ok(old_id) => Some(old_id), } }; + let (is_incremental, outcome) = if let Some(old_id) = old_id { + info!("incremental backup based on {}", old_id); + let mut run = BackupRun::incremental(config, &client)?; + let old = run.start(Some(&old_id), &oldtemp, perf).await?; + ( + true, + run.backup_roots(config, &old, &newtemp, schema, perf) + .await?, + ) + } else { + info!("fresh backup without a previous generation"); + let mut run = BackupRun::initial(config, &client)?; + let old = run.start(None, &oldtemp, perf).await?; + ( + false, + run.backup_roots(config, &old, &newtemp, schema, perf) + .await?, + ) + }; + perf.start(Clock::GenerationUpload); let mut trust = trust; trust.append_backup(outcome.gen_id.as_chunk_id()); |