summaryrefslogtreecommitdiff
path: root/src/cmd/backup.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/backup.rs')
-rw-r--r--src/cmd/backup.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/cmd/backup.rs b/src/cmd/backup.rs
index 92b0f40..dae9811 100644
--- a/src/cmd/backup.rs
+++ b/src/cmd/backup.rs
@@ -3,13 +3,14 @@
use crate::backup_run::BackupRun;
use crate::client::BackupClient;
use crate::config::ClientConfig;
+use crate::dbgen::FileId;
use crate::error::ObnamError;
use crate::generation::GenId;
use log::info;
use std::time::SystemTime;
use structopt::StructOpt;
-use tempfile::NamedTempFile;
+use tempfile::tempdir;
use tokio::runtime::Runtime;
/// Make a backup.
@@ -29,21 +30,22 @@ impl Backup {
let client = BackupClient::new(config)?;
let genlist = client.list_generations().await?;
- let oldtemp = NamedTempFile::new()?;
- let newtemp = NamedTempFile::new()?;
+ let temp = tempdir()?;
+ 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.path()).await?;
- (false, run.backup_roots(config, &old, newtemp.path()).await?)
+ let old = run.start(None, &oldtemp).await?;
+ (false, run.backup_roots(config, &old, &newtemp).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.path()).await?;
- (true, run.backup_roots(config, &old, newtemp.path()).await?)
+ let old = run.start(Some(&old_id), &oldtemp).await?;
+ (true, run.backup_roots(config, &old, &newtemp).await?)
}
};
@@ -76,7 +78,7 @@ impl Backup {
fn report_stats(
runtime: &SystemTime,
- file_count: i64,
+ file_count: FileId,
gen_id: &GenId,
num_warnings: usize,
) -> Result<(), ObnamError> {