From f2b318f91a79de8e85afe169ee45e26ac76c2514 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sat, 24 May 2025 12:09:32 +0200 Subject: [PATCH] add config file for restore --- config.yaml | 2 ++ restore | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 config.yaml diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..cfd6770 --- /dev/null +++ b/config.yaml @@ -0,0 +1,2 @@ +backup_path: /images/backup +backup_name: sicherung diff --git a/restore b/restore index ec24179..06afe12 100755 --- a/restore +++ b/restore @@ -36,12 +36,15 @@ restore() local number="$2" local machine="$3" local path="$4" - local backup_root="/images/backup" - local backup_name="sicherung" + local backup_root=$(cat config.yaml | yq -r '.backup_path') + local backup_name=$(cat config.yaml | yq -r '.backup_name') [ -d "$backup_root" ] \ || errlog "could not find directory $backup_root" \ || return $? + [ "$backup_name" != "null" ] \ + || errlog "missing backup name" \ + || return $? local remote_user=${machine%%@*} local remote_machine=${machine%:*} @@ -134,6 +137,13 @@ main() esac done + command -v yq > /dev/null || errlog "yq command not found" || return $? + command -v rsync > /dev/null \ + || errlog "rsync command not found" \ + || return $? + [ -f "config.yaml" ] \ + || errlog "file config.yaml not found" \ + || return $? [ -n "$date" ] || errlog "missing date (-d)" || return $? [ -n "$number" ] || errlog "missing number (-n)" || return $? [ -n "$machine" ] || errlog "missing machine (-r)" || return $? -- 2.47.3