diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-03-21 09:12:49 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-03-22 19:18:35 +0200 |
commit | 48139725676fcce89a70897546969623f2474693 (patch) | |
tree | f9c00d2fcd3b7c597fd5062b90ef2279eb9db767 /src/cmd/backup.rs | |
parent | 4c94c794ec805cf643826973e4f83826a1231e54 (diff) | |
download | obnam2-48139725676fcce89a70897546969623f2474693.tar.gz |
feat! store list of generations in a "client trust root" chunk
Backups made with this version can't be restored with old clients, and
vice version.
Sponsored-by: author
Diffstat (limited to 'src/cmd/backup.rs')
-rw-r--r-- | src/cmd/backup.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/cmd/backup.rs b/src/cmd/backup.rs index 6983de4..db65da0 100644 --- a/src/cmd/backup.rs +++ b/src/cmd/backup.rs @@ -1,6 +1,7 @@ //! The `backup` subcommand. -use crate::backup_run::BackupRun; +use crate::backup_run::{current_timestamp, BackupRun}; +use crate::chunk::ClientTrust; use crate::client::BackupClient; use crate::config::ClientConfig; use crate::dbgen::{schema_version, FileId, DEFAULT_SCHEMA_MAJOR}; @@ -37,7 +38,12 @@ impl Backup { eprintln!("backup: schema: {}", schema); let client = BackupClient::new(config)?; - let genlist = client.list_generations().await?; + let trust = client + .get_client_trust() + .await? + .or_else(|| Some(ClientTrust::new("FIXME", None, current_timestamp(), vec![]))) + .unwrap(); + let genlist = client.list_generations(&trust); let temp = tempdir()?; let oldtemp = temp.path().join("old.db"); @@ -64,6 +70,13 @@ impl Backup { } }; + let mut trust = trust; + trust.append_backup(outcome.gen_id.as_chunk_id()); + trust.finalize(current_timestamp()); + let trust = trust.to_data_chunk()?; + let trust_id = client.upload_chunk(trust).await?; + info!("uploaded new client-trust {}", trust_id); + for w in outcome.warnings.iter() { println!("warning: {}", w); } |