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)
[ "$remote_port" != "null" ] \
|| errlog "config.yaml missing port" \
|| return $?
+ rsyncargs+=("--rsh=\"ssh -p $remote_port\"")
local backup_dir="$date"_"$number"_"$backup_name"
|| 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"
[ -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"
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 $?