From b90cbf59585ac9f7ac34372d532ccecce8f51bc0 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sat, 27 Jun 2026 20:26:12 +0200 Subject: [PATCH] fix restore with localhost --- src/restore | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/restore b/src/restore index 6987704..d2e46f8 100755 --- a/src/restore +++ b/src/restore @@ -40,6 +40,12 @@ restore() local remote_user= local remote_machine= local remote_port= + local rsyncargs=("--archive" \ + "--verbose" \ + "--sparse" \ + "--acls" \ + "--hard-links" \ + "--human-readable") backup_path=$(yq --raw-output ".backup_path" config.yaml) backup_name=$(yq --raw-output ".backup_name" config.yaml) @@ -69,6 +75,7 @@ restore() [ "$remote_port" != "null" ] \ || errlog "config.yaml missing port" \ || return $? + rsyncargs+=("--rsh=\"ssh -p $remote_port\"") local backup_dir="$date"_"$number"_"$backup_name" @@ -82,7 +89,9 @@ restore() || return $? local restore_path="$restore_prefix_path$path" - local remote_path="$remote_user@$remote_machine:$path" + + local hostpath="$remote_user@$remote_machine:$path" + [ "$remote_machine" == "localhost" ] && local hostpath="$path" local mode="directory" [[ "$path" =~ /$ ]] || mode="file" @@ -90,16 +99,18 @@ restore() [ -f "$restore_path" ] || [ -d "$restore_path" ] \ || errlog "could not find $restore_path" \ || return $? + rsyncargs+=("$restore_path") + rsyncargs+=("$hostpath") echo "ℹ️ INFO: restore mode $mode" echo echo "ℹ️ INFO: restore path $restore_path" - echo "ℹ️ INFO: remote path $remote_path" + echo "ℹ️ INFO: remote path $hostpath" echo [ "$origin" == "deletemode-on" ] \ - && local deletemode="--delete" \ + && rsyncargs+=("--delete") \ && echo "⚠️ WARN: delete mode on" && echo local ask_restore="N" @@ -114,16 +125,7 @@ restore() echo "ℹ️ INFO: restoring..." - rsync --archive \ - --verbose \ - --sparse \ - --acls \ - --hard-links \ - --human-readable \ - "$deletemode" \ - --rsh "ssh -p $remote_port" \ - "$restore_path" \ - "$remote_path" \ + rsync "${rsyncargs[@]}" \ || errlog "could not restore" \ || return $? -- 2.47.3