From 8ee4953089def6b01c1fb835fe218f73d20127fb Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sat, 24 May 2025 11:20:22 +0200 Subject: [PATCH] add checks exists path --- restore | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 -- 2.47.3