2 Incheckningar 5bf285bfac ... 5922ae4880

Upphovsman SHA1 Meddelande Datum
  Kevin Heinicke 5922ae4880 Add backup script installation 1 år sedan
  Kevin Heinicke af789030cf Merge upstream 1 år sedan
3 ändrade filer med 41 tillägg och 7 borttagningar
  1. 1 1
      coc-extensions.json
  2. 3 0
      install.conf.yaml
  3. 37 6
      scripts/backup_server_to_disk.sh

+ 1 - 1
coc-extensions.json

@@ -10,5 +10,5 @@
   },
   "disabled": [],
   "locked": [],
-  "lastUpdate": 1718568819938
+  "lastUpdate": 1720382612933
 }

+ 3 - 0
install.conf.yaml

@@ -34,3 +34,6 @@
     ~/.config/sheldon/plugins.toml:
         create: true
         path: sheldon-plugins.toml
+    ~/.local/bin/backup_server_to_disk:
+        create: true
+        path: scripts/backup_server_to_disk.sh

+ 37 - 6
scripts/backup_server_to_disk.sh

@@ -1,22 +1,53 @@
 #!/bin/bash
 
-DISK=/Volumes/Server
-SERVER=cnew
+SERVER=${1:-"cnew"}
+DISK=${2:-"/Volumes/Server"}
+BWLIMIT=${3:-"0"}
+ONLY_RASPI=${4:-"N"}
+
+echo "Backing up server $SERVER to disk $DISK."
+
+if [[ "$BWLIMIT" != "0" ]]; then
+    echo "I/O bandwidth limit (rsync --bwlimit) is $BWLIMIT"
+fi
+
+if [[ "$ONLY_RASPI" == "Y" ]]; then
+    echo "Skipping main backup. Only backing up raspi"
+fi
+
+read -n 1 -p "Press Y to continue: " userinput
+echo
+if [[ "$userinput" != "Y" ]]; then
+    echo "Abort."
+    exit
+else
+    echo "Backing up."
+fi
+
+
 
 # Basic snapshot-style rsync backup script
 date=`date "+%Y-%m"`
 
 # Run rsync to create snapshot
 # exclude backups on the remote to prevent filling with hardlinks
-rsync -aPhRz \
-    --exclude "*-backup*/*" --exclude="*cache*" --rsync-path "sudo rsync" \
-    --link-dest=$DISK/last $SERVER:/etc :/home :/var :/root $DISK/$date
+if [[ "$ONLY_RASPI" != "Y" ]]; then
+    rsync -aPhRz \
+        --bwlimit=$BWLIMIT \
+        --exclude "*-backup*/*" --exclude="*cache*" --rsync-path "sudo rsync" \
+        --link-dest=$DISK/last $SERVER:/etc :/home :/var :/root $DISK/$date
+else
+    echo "Skipped main backup"
+fi
 
 # copy lastest backups by following symlinks
 # need to explicitly include each level of directories before adding a global
 # */last pattern
 rsync -aPhRzLK \
-    --include "var/" --include "*-backups/" --include "home/raspi-backup/" \
+    --bwlimit=$BWLIMIT \
+    --include "var/" --include "*-backups/" \
+    --exclude ".npm/*" --exclude "*cache*/*" \
+    --include "home/" --include "home/raspi-backup/" \
     --include "*-backup*/last" --include "*-backup*/last/**" --exclude="*" --rsync-path "sudo rsync" \
     --link-dest=$DISK/last $SERVER:/home/raspi-backup :/var $DISK/$date