]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add config file for restore
authorBastian Dehn <hhaalo@arcor.de>
Sat, 24 May 2025 10:09:32 +0000 (12:09 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 24 May 2025 10:09:32 +0000 (12:09 +0200)
config.yaml [new file with mode: 0644]
restore

diff --git a/config.yaml b/config.yaml
new file mode 100644 (file)
index 0000000..cfd6770
--- /dev/null
@@ -0,0 +1,2 @@
+backup_path: /images/backup
+backup_name: sicherung
diff --git a/restore b/restore
index ec241793d53dd8a412b616e16f1d6317fe39a685..06afe127b75349fc93207700b0b7f56df3007612 100755 (executable)
--- 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 $?