]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add checks exists path
authorBastian Dehn <hhaalo@arcor.de>
Sat, 24 May 2025 09:20:22 +0000 (11:20 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 24 May 2025 09:24:11 +0000 (11:24 +0200)
restore

diff --git a/restore b/restore
index b37ef76bf5af961f0c0213ab604c67490877bf3b..ec241793d53dd8a412b616e16f1d6317fe39a685 100755 (executable)
--- a/restore
+++ b/restore
@@ -39,19 +39,34 @@ restore()
        local backup_root="/images/backup"
        local backup_name="sicherung"
 
+       [ -d "$backup_root" ] \
+               || errlog "could not find directory $backup_root" \
+               || return $?
+
        local remote_user=${machine%%@*}
        local remote_machine=${machine%:*}
        local remote_machine=${remote_machine#*@}
        local remote_port=${machine##*:}
        local backup_dir="$date"_"$number"_"$backup_name"
 
+       [ -d "$backup_root/$backup_dir" ] \
+               || errlog "could not find directory $backup_root/$backup_dir" \
+               || return $?
+
+       [ -d "$backup_root/$backup_dir/$remote_machine" ] \
+               || errlog "could not find directory $backup_root/$backup_dir/$remote_machine" \
+               || return $?
+
        local restore_path="$backup_root/$backup_dir/$remote_machine$path"
        local remote_path="$remote_user@$remote_machine:$path"
 
        local mode="directory"
-
        [[ "$path" =~ /$ ]] || mode="file"
 
+       [ -f "$restore_path" ] || [ -d "$restore_path" ] \
+               || errlog "could not find $restore_path" \
+               || return $?
+
        echo "ℹ️  INFO: restore mode $mode"
        echo