diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-11-28 06:33:36 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-11-28 06:33:36 +0000 |
commit | 552a2ada34af32691020dc21ea321eefbbce389f (patch) | |
tree | 7a88381b98637fa723f699feb6ad40a2725b1ace | |
parent | 8d00d6e452638cbb5418887d0057b95d777a8fa0 (diff) | |
parent | 9dcd23354ec74daf4000ec40bd52a33341a16cd8 (diff) | |
download | obnam2-552a2ada34af32691020dc21ea321eefbbce389f.tar.gz |
Merge branch 'non-existent-backup-root' into 'main'
feat! turn errors from backup root directory into errors
Closes #132
See merge request obnam/obnam!191
-rw-r--r-- | obnam.md | 20 | ||||
-rw-r--r-- | src/backup_run.rs | 11 | ||||
-rw-r--r-- | src/generation.rs | 3 |
3 files changed, 32 insertions, 2 deletions
@@ -1337,6 +1337,26 @@ roots: [live] ~~~ +## Backup root must exist + +This scenario verifies that Obnam correctly reports an error if a +backup root directory doesn't exist. + +~~~scenario +given a working Obnam system +and a client config based on missingroot.yaml +and a file live/data.dat containing some random data +when I try to run obnam backup +then command fails +then stderr contains "does-not-exist" +~~~ + +~~~{#missingroot.yaml .file .yaml .numberLines} +verify_tls_cert: false +roots: [live, does-not-exist] +~~~ + + ## Back up regular file The scenarios in this section back up a single regular file each, and diff --git a/src/backup_run.rs b/src/backup_run.rs index fb823be..0853bdf 100644 --- a/src/backup_run.rs +++ b/src/backup_run.rs @@ -164,9 +164,8 @@ impl<'a> BackupRun<'a> { } } Err(err) => { - debug!("ignoring backup error {}", err); - warnings.push(err.into()); self.found_problem(); + return Err(err.into()); } } } @@ -193,9 +192,16 @@ impl<'a> BackupRun<'a> { let mut warnings: Vec<BackupError> = vec![]; let mut new_cachedir_tags = vec![]; let iter = FsIterator::new(root, config.exclude_cache_tag_directories); + let mut first_entry = true; for entry in iter { match entry { Err(err) => { + if first_entry { + // Only the first entry (the backup root) + // failing is an error. Everything else is a + // warning. + return Err(NascentError::BackupRootFailed(root.to_path_buf(), err)); + } warnings.push(err.into()); } Ok(entry) => { @@ -217,6 +223,7 @@ impl<'a> BackupRun<'a> { } } } + first_entry = false; } Ok(OneRootBackupOutcome { diff --git a/src/generation.rs b/src/generation.rs index 33750ca..6613c02 100644 --- a/src/generation.rs +++ b/src/generation.rs @@ -53,6 +53,9 @@ pub struct NascentGeneration { #[derive(Debug, thiserror::Error)] pub enum NascentError { + #[error("Could not back up a backup root directory: {0}: {1}")] + BackupRootFailed(PathBuf, crate::fsiter::FsIterError), + #[error(transparent)] LocalGenerationError(#[from] LocalGenerationError), |