]> git.treefish.org Git - backmeupscotty.git/commitdiff
Add FAKE_SUPER and REMOTE_HOST vars
authorAlexander Schmidt <alex@treefish.org>
Mon, 26 Feb 2024 19:49:15 +0000 (20:49 +0100)
committerAlexander Schmidt <alex@treefish.org>
Mon, 26 Feb 2024 19:49:15 +0000 (20:49 +0100)
backmeupscotty
backmeupscotty-example

index 65e4d53310b732200dc2c67edcd941f7caaf2b31..87dc1933ae0060734df6cc31ab154ddf0ab2c297 100644 (file)
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+REMOTE_USER=root
 REMOTE_HOST=localhost
 REMOTE_DIR=/tmp/backmeupscotty/test
 ARCHIVE_KEEPNBACKUPS=30
@@ -7,6 +8,7 @@ ARCHIVE_KEEPNDAYS=30
 BACKUP_RUNEVERYNTHDAY=1
 BWLIMIT=500KiB
 BACKUP_FORCE=0
+FAKE_SUPER=0
 
 _ERROR_ENCOUNTERED=0
 
@@ -105,6 +107,12 @@ function scottysync {
         rsync_exclude=$(eval echo --exclude={$SYNC_EXC} | tr -d {})
     fi
 
+    if [ $FAKE_SUPER -eq 1 ]; then
+        rsync_fake_super="--rsync-path=\"rsync --fake-super\""
+    else
+        rsync_fake_super=""
+    fi
+
     if (ssh255 $REMOTE_HOST '[ ! -d '$REMOTE_DIR' ]'); then
         scottyinfo "Creating destination directory $REMOTE_HOST:$REMOTE_DIR."
         ssh255 $REMOTE_HOST "mkdir $REMOTE_DIR"
@@ -118,8 +126,8 @@ function scottysync {
     rsync -e ssh --bwlimit=$BWLIMIT \
           -v -aHAX --numeric-ids --delete --delete-excluded \
           --link-dest=$dir_current \
-          $rsync_exclude \
-          $SYNC_SRC/ $REMOTE_HOST:$dir_incomplete/
+          $rsync_exclude $rsync_fake_super \
+          $SYNC_SRC/ $REMOTE_USER@$REMOTE_HOST:$dir_incomplete/
 
     if [ $? -eq 0 ]; then
         scottyinfo "Timestamping completed backup and linking to current backup."
@@ -192,10 +200,10 @@ EOF
 
 function exclusiveLock {
     if ! mkdir /var/lock/$(basename $0); then
-       scottyerror "Another instance of $(basename $0) is still running!"
-       exit 1
+        scottyerror "Another instance of $(basename $0) is still running!"
+        exit 1
     else
-       trap deleteLock EXIT
+        trap deleteLock EXIT
     fi
 }
 
@@ -211,9 +219,9 @@ function backmeupscotty {
             f)
                 BACKUP_FORCE=1
                 ;;
-           l)
-               LIST_BACKUPS=1
-               ;;
+            l)
+                LIST_BACKUPS=1
+                ;;
             h)
                 printhelp
                 exit 0
@@ -224,10 +232,10 @@ function backmeupscotty {
     ssh255 $REMOTE_HOST exit
 
     if [ $LIST_BACKUPS ]; then
-       for backup in $(grepbackups); do
-           echo $backup
-       done
-       exit 0
+        for backup in $(grepbackups); do
+            echo $backup
+        done
+        exit 0
     fi
 
     exclusiveLock
index 15b05b561ade336fc39e8ce9dc3db936c555712b..77ee11e3130c4b71abd0b6faa8fc870e2320a7bf 100755 (executable)
@@ -2,6 +2,7 @@
 
 . ./backmeupscotty
 
+REMOTE_USER=root
 REMOTE_HOST=localhost
 REMOTE_DIR=/tmp/scotty/dest
 ARCHIVE_KEEPNBACKUPS=10
@@ -10,6 +11,7 @@ BACKUP_RUNEVERYNTHDAY=1
 SYNC_SRC="/tmp/scotty/src"
 SYNC_EXC="/gack,/gugu/*"
 BWLIMIT=600KiB
+FAKE_SUPER=0
 
 function prepare {
     echo "prepare"