From 695ffbb476b38a7fb94786d863b58749002def5b Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 25 May 2025 16:01:03 +0200 Subject: [PATCH] add origin delete mode by restore --- restore | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/restore b/restore index f22aae6..67d441d 100755 --- a/restore +++ b/restore @@ -37,7 +37,9 @@ restore() local number="$2" local machine="$3" local path="$4" - local key="$5" + local origin="$5" + local key="$6" + local deletemode= local backup_root=$(cat config.yaml \ | yq --raw-output '.backup_path') local backup_name=$(cat config.yaml \ @@ -70,6 +72,10 @@ restore() local restore_path="$restore_prefix_path$path" local remote_path="$remote_user@$remote_machine:$path" + [ "$origin" == "deletemode-on" ] \ + && deletemode="--delete" \ + && echo "ℹ️ INFO: delete mode on" + local mode="directory" [[ "$path" =~ /$ ]] || mode="file" @@ -102,6 +108,7 @@ restore() --acls \ --hard-links \ --human-readable \ + $deletemode \ --rsh "ssh -p $remote_port" \ $restore_path \ $remote_path \ @@ -118,16 +125,18 @@ main() local machine= local path= local key= + local origin="deletemode-off" echo "⭐ START: restore" - while getopts "d:k:n:r:p:h" optname; do + while getopts "d:k:n:r:p:ho" optname; do case "$optname" in "d") date="$OPTARG" ;; "k") key="$OPTARG" ;; "n") number="$OPTARG" ;; "r") machine="$OPTARG" ;; "p") path="$OPTARG" ;; + "o") origin="deletemode-on" ;; "h") useage && return 0 ;; esac done @@ -150,7 +159,7 @@ main() || return $? [ -n "$path" ] || errlog "missing path (-p)" || return $? - restore "$date" "$number" "$machine" "$path" "$key" \ + restore "$date" "$number" "$machine" "$path" "$origin" "$key" \ || return $? echo "✅ SUCCESS: restore" -- 2.47.3