Updated scripts/rsyncbackup.sh (variable name changes).
authorZoltán Felleg <zoltan.felleg@userrendszerhaz.hu>
Thu, 13 Mar 2025 15:33:17 +0000 (16:33 +0100)
committerZoltán Felleg <zoltan.felleg@userrendszerhaz.hu>
Thu, 13 Mar 2025 15:33:17 +0000 (16:33 +0100)
scripts/rsyncbackup.sh

index 88a975c0b75119ade37e2f76ec0dbc7a93c9dab9..00440c9cc9488bdf7bf31b36740023464a47e248 100755 (executable)
@@ -1,33 +1,47 @@
 #!/bin/sh
 
 
-RSYNCBIN="/usr/bin/rsync"
-RSYNCOPTS="--archive \
-           --contimeout=60 \
-           --delete-after \
-           --delete-excluded \
-           --exclude=lost+found \
-           --hard-links \
-           --no-motd \
-           --partial-dir=.partial \
-           --sparse \
-           --timeout=60 \
-           --verbose"
-SCRIPTDATE=$(date +%Y%m%d%H)
-SCRIPTNAME=$(basename $0)
+SCRIPT_NAME=$(basename $0)
+RSYNC_BINARY="/usr/bin/rsync"
+RSYNC_OPTIONS="--archive \
+               --chmod=Fgo+r \
+               --contimeout=60 \
+               --delete-after \
+               --delete-excluded \
+               --exclude=lost+found \
+               --hard-links \
+               --log-file=/var/log/rsync.log \
+               --log-file-format=\"%o %m %f %l\" \
+               --no-motd \
+               --partial-dir=.partial \
+               --sparse \
+               --timeout=60"
 
-if [ "$SCRIPTNAME" = "rsyncbackup.sh" ]
+if [ "$SCRIPT_NAME" = "cron.rsyncbackup.sh" ]
 then
-    RSYNCOPTS="$RSYNCOPTS --progress"
+    RUNNING_FROM_CRON=1
+else
+    RUNNING_FROM_CRON=0
 fi
 
-RSYNC="$RSYNCBIN $RSYNCOPTS"
+if [ $RUNNING_FROM_CRON -eq 1 ]
+then
+    echo
+    echo "================================="
+    echo "====   $SCRIPT_NAME   ===="
+    echo "================================="
+    /usr/bin/date >/lxc/filesystems/state
+fi
+
+RSYNC="$RSYNC_BINARY $RSYNC_OPTIONS"
+
 
-TARGETHOST=store.10g.useribm.hu
-TARGETMODULE=backup
-echo "Syncing module lxc-filesystems to $TARGETHOST"
+TARGET_HOST=store.10g.useribm.hu
+TARGET_MODULE=backup
+echo "Syncing module lxc-filesystems to $TARGET_HOST"
 date
-$RSYNC /lxc/filesystems/ ${TARGETHOST}::$TARGETMODULE/lxc-filesystems
+echo $RSYNC /lxc/filesystems/ ${TARGET_HOST}::$TARGET_MODULE/lxc-filesystems >/tmp/rsync.$$
+bash /tmp/rsync.$$
 RSYNC_RC=$?
 TRIES=1
 while [ $RSYNC_RC -ne 0 ]
@@ -38,9 +52,10 @@ do
     fi
     echo
     echo "${TRIES}. retry"
-    $RSYNC /lxc/filesystems/ ${TARGETHOST}::$TARGETMODULE/lxc-filesystems
+    bash /tmp/rsync.$$
     RSYNC_RC=$?
     TRIES=$(( $TRIES + 1 ))
 done
+rm --force /tmp/rsync.$$
 date
 echo