Browse Source

Update backup scripts

master
David Trudgian 3 months ago
parent
commit
c5c8754eb9
  1. 14
      bin/backup_lab.sh
  2. 19
      bin/backup_piran.sh
  3. 2
      bin/backup_ythel.sh
  4. 7
      bin/tar-subdirs.sh

14
bin/backup_lab.sh

@ -1,8 +1,7 @@
#!/usr/bin/env bash
HOST="piran"
DEST_LOCAL="/backup/borg_lab"
DEST_RCLONE="b2:randomroad-lab"
DEST_LOCAL="/data/borg/borg_lab"
SOURCE_HOSTS=( pi3.home pi4.home )
if [ $(hostname -s) != "${HOST}" ]; then
@ -10,10 +9,6 @@ if [ $(hostname -s) != "${HOST}" ]; then
exit 255
fi
echo "Mounting Backup Drive"
sudo cryptsetup luksOpen /dev/disk/by-uuid/dd56bd4c-0c48-426b-9b2c-ede44059695d crypt_backup
sudo mount /dev/mapper/crypt_backup /backup
for host in "${SOURCE_HOSTS[@]}"
do
echo "Updating pool for ${host}..."
@ -25,14 +20,11 @@ do
--exclude "/tmp" \
--exclude "/kern" \
--exclude "/var/lib/docker" \
"root@${host}.randomroad.net:/" "/backup/pool_lab_${host}"
"root@${host}.randomroad.net:/" "/data/backup/pool/pool_lab_${host}"
done
echo "Local Backup to ${DEST_LOCAL}"
borg create -s --progress "${DEST_LOCAL}::$(date '+%Y%m%d-%H%M')" /backup/pool_lab_*
echo "Sync to ${DEST_RCLONE}"
b2 sync --delete "${DEST_LOCAL}" "${DEST_RCLONE}"
borg create -s --progress "${DEST_LOCAL}::$(date '+%Y%m%d-%H%M')" /data/backup/pool/pool_lab_*
echo
echo DONE

19
bin/backup_piran.sh

@ -1,28 +1,15 @@
#!/usr/bin/env bash
HOST="piran"
DEST_LOCAL="/backup/borg_${HOST}"
DEST_RCLONE="b2:randomroad-${HOST}"
SOURCES="/home /etc /var /data/Shared"
DEST_LOCAL="/data/borg/borg_${HOST}"
SOURCES="/home /etc /var"
if [ $(hostname -s) != "${HOST}" ]; then
echo "Must be run from ${HOST}"
exit 255
fi
echo "Mounting Backup Drive"
sudo cryptsetup luksOpen /dev/disk/by-uuid/dd56bd4c-0c48-426b-9b2c-ede44059695d crypt_backup
sudo mount /dev/mapper/crypt_backup /backup
echo "Local Backup to ${DEST_LOCAL}"
sudo borg create -s --progress "dave@127.0.0.1:${DEST_LOCAL}::$(date '+%Y%m%d-%H%M')" ${SOURCES}
echo "Sync to ${DEST_RCLONE}"
b2 sync --delete "${DEST_LOCAL}" "${DEST_RCLONE}"
echo "Un-Mounting Backup Drive"
sudo umount /backup
sudo cryptsetup close crypt_backup
sudo borg create -s --progress "${DEST_LOCAL}::$(date '+%Y%m%d-%H%M')" ${SOURCES}
echo
echo DONE

2
bin/backup_ythel.sh

@ -1,6 +1,6 @@
#!/usr/bin/env bash
HOST="ythel"
DEST_LOCAL="/backup/borg_${HOST}"
DEST_LOCAL="/data2/borg/borg_${HOST}"
SOURCES="/home /etc /var /data1/kvm /data1/nfs /data1/pvc"
if [ $(hostname -s) != "${HOST}" ]; then

7
bin/tar-subdirs.sh

@ -0,0 +1,7 @@
#!/bin/bash
for subdir in $(find . -mindepth 1 -maxdepth 1 -type d); do
echo "Compressing $subdir..."
base=$(basename "$subdir")
tar -cJf "$base.tar.xz" "$base"
done
Loading…
Cancel
Save