From: Bastian Dehn Date: Sat, 15 Aug 2026 12:48:58 +0000 (+0200) Subject: check machine path X-Git-Tag: v1.0.7^2~3^2~6 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=3226e13f07fc8bd8b531493eba3b7fb8ff8fbe44;p=simple-backup.git check machine path --- diff --git a/src/restore b/src/restore index 8a181be..e418cf2 100755 --- a/src/restore +++ b/src/restore @@ -102,6 +102,9 @@ restore() [ -d "$backup_path/$backup_dir" ] \ || errlog "directory $backup_path/$backup_dir not exists" \ || return $? + [ -d "$backup_path/$backup_dir/$machine" ] \ + || errlog "directory $backup_path/$backup_dir/$machine not exists" \ + || return $? } main() diff --git a/tests/restore_tests.bats b/tests/restore_tests.bats index cf3913e..ff161f7 100755 --- a/tests/restore_tests.bats +++ b/tests/restore_tests.bats @@ -279,4 +279,17 @@ teardown() { assert_line --index 1 "ℹ️ INFO: backup path build/test" assert_line --index 2 "ℹ️ INFO: backup name backup" assert_line --index 3 "❌ ERROR: directory build/test/2000-01-01_01_backup not exists" +} + +# bats test_tags=backup:pathcheck +@test "failure no backup directory machine" { + mkdir --parents "build/test/2000-01-01_01_backup" + + run main -d "2000-01-01" -n "01" -r "testpc1.example.com" -p "/testpath" + + assert_failure + assert_line --index 0 "⭐ START: restore" + assert_line --index 1 "ℹ️ INFO: backup path build/test" + assert_line --index 2 "ℹ️ INFO: backup name backup" + assert_line --index 3 "❌ ERROR: directory build/test/2000-01-01_01_backup/testpc1.example.com not exists" } \ No newline at end of file