]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add origin delete mode by restore
authorBastian Dehn <hhaalo@arcor.de>
Sun, 25 May 2025 14:01:03 +0000 (16:01 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 25 May 2025 14:01:03 +0000 (16:01 +0200)
restore

diff --git a/restore b/restore
index f22aae6574ecbdb5f5c1232520a91181f2cb9619..67d441dbf223165a5e43b13245319d40fbeee314 100755 (executable)
--- 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"