From: Bastian Dehn Date: Sat, 24 May 2025 09:20:22 +0000 (+0200) Subject: add checks exists path X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=8ee4953089def6b01c1fb835fe218f73d20127fb;p=simple-backup.git add checks exists path --- diff --git a/restore b/restore index b37ef76..ec24179 100755 --- 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