diff options
author | Tharre <tharre3@gmail.com> | 2022-01-07 21:35:28 +0100 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2023-04-25 05:33:37 +0200 |
commit | 051d76ba0e5408cae656d30079816952536cee9b (patch) | |
tree | 680799952307854a89aec5bc4d0e5c2daaf2d221 | |
parent | 59744df0d95e0a51572bfafee03de5979d810f6c (diff) | |
download | pkgbuilds-051d76ba0e5408cae656d30079816952536cee9b.tar.gz pkgbuilds-051d76ba0e5408cae656d30079816952536cee9b.tar.xz pkgbuilds-051d76ba0e5408cae656d30079816952536cee9b.zip |
arch-system: backup system updates
-rw-r--r-- | arch-system/.SRCINFO | 8 | ||||
-rw-r--r-- | arch-system/PKGBUILD | 6 | ||||
-rwxr-xr-x | arch-system/backup-sudo | 11 | ||||
-rw-r--r-- | arch-system/borg-backup.service | 1 | ||||
-rwxr-xr-x | arch-system/borgbackup | 37 |
5 files changed, 30 insertions, 33 deletions
diff --git a/arch-system/.SRCINFO b/arch-system/.SRCINFO index 492a92f..706057b 100644 --- a/arch-system/.SRCINFO +++ b/arch-system/.SRCINFO @@ -1,6 +1,6 @@ pkgbase = arch-system pkgdesc = Arch Linux system configuration - pkgver = 2021.12.18 + pkgver = 2022.05.25 pkgrel = 1 arch = any license = custom @@ -32,10 +32,10 @@ pkgbase = arch-system sha256sums = 7467bb40e7d404ed249b34a0e410b8d452ebc4b90588d7e210bfa47011b5981d sha256sums = dd84877b7f6f4330da489fa33f843c9a7c862562a3d78dc2feea5116ac846a79 sha256sums = 483a7d9350653c2cf22f36f67f1a83cc5c95232dfc10642a20d76e3c32c9e2e3 - sha256sums = 0fd2628f2311fbbc4dae6f3018b27976ff20f8d70175bc3a587696350295028c - sha256sums = 42050ba722df1cd606288e82054e131dac99bf10506f4c8d52eb9bfc0a078d89 + sha256sums = d39732bec90036020ad94d52cb34b6215801a82595f7fb30f8c5e0a7f1eb9b1e + sha256sums = 94c06cbf7304996b0503cace9394c2dbc0150bc045fd30cc402e3d943a8c8abd sha256sums = e1bf3dc5978a7641f86975b7ee770a6914b30a8e4b7e3be2f1b07eaa7098591d - sha256sums = 35e501f1114f635a4c55ccf2c9debcdff5579666dcf6d11e695be861ebd0a436 + sha256sums = 276a79a04359ffae6ddf597d060278f6f58890ce2d5f6c185948b31c7a5c8927 sha256sums = 895305808aa91be3294dbaeb7840e38497fb8dbcd6309cc95c417e1a0379e596 sha256sums = 5613c98d32e513a973e8a0e250ab0b267882a73615f507b6208d4a5f21487fe6 diff --git a/arch-system/PKGBUILD b/arch-system/PKGBUILD index 44faee5..bba13bf 100644 --- a/arch-system/PKGBUILD +++ b/arch-system/PKGBUILD @@ -27,10 +27,10 @@ sha256sums=('271d6a7ac30da0d2ba055067d4ebbab76812c1735e4c2b45c619e004edc1fbba' '7467bb40e7d404ed249b34a0e410b8d452ebc4b90588d7e210bfa47011b5981d' 'dd84877b7f6f4330da489fa33f843c9a7c862562a3d78dc2feea5116ac846a79' '483a7d9350653c2cf22f36f67f1a83cc5c95232dfc10642a20d76e3c32c9e2e3' - '0fd2628f2311fbbc4dae6f3018b27976ff20f8d70175bc3a587696350295028c' - '42050ba722df1cd606288e82054e131dac99bf10506f4c8d52eb9bfc0a078d89' + 'd39732bec90036020ad94d52cb34b6215801a82595f7fb30f8c5e0a7f1eb9b1e' + '94c06cbf7304996b0503cace9394c2dbc0150bc045fd30cc402e3d943a8c8abd' 'e1bf3dc5978a7641f86975b7ee770a6914b30a8e4b7e3be2f1b07eaa7098591d' - '35e501f1114f635a4c55ccf2c9debcdff5579666dcf6d11e695be861ebd0a436' + '276a79a04359ffae6ddf597d060278f6f58890ce2d5f6c185948b31c7a5c8927' '895305808aa91be3294dbaeb7840e38497fb8dbcd6309cc95c417e1a0379e596' '5613c98d32e513a973e8a0e250ab0b267882a73615f507b6208d4a5f21487fe6') diff --git a/arch-system/backup-sudo b/arch-system/backup-sudo index 1091451..90590e0 100755 --- a/arch-system/backup-sudo +++ b/arch-system/backup-sudo @@ -12,8 +12,13 @@ validate_path() { case "$1" in snapshot) validate_path "$2" - touch /home - btrfs subvolume snapshot -r -- /home "$2" + # small race, but shouldn't matter + if ! btrfs subvolume show "$3" > /dev/null 2>&1; then + echo "Not a btrfs subvolume." >&2 + exit 3 + fi + touch -c -- "$3" + btrfs subvolume snapshot -r -- "$3" "$2" ;; delete_snapshot) validate_path "$2" @@ -26,7 +31,7 @@ case "$1" in ;; cleanup) umount /backup 2> /dev/null || true - rm -rf /backup + rm -df /backup ;; *) echo "No command specified." >&2 diff --git a/arch-system/borg-backup.service b/arch-system/borg-backup.service index 689ac75..b5a4a52 100644 --- a/arch-system/borg-backup.service +++ b/arch-system/borg-backup.service @@ -4,6 +4,7 @@ Wants=network-online.target After=network-online.target [Service] +RuntimeMaxSec=1800 Nice=19 IOSchedulingClass=3 IOSchedulingPriority=7 diff --git a/arch-system/borgbackup b/arch-system/borgbackup index e16eec3..c813fcc 100755 --- a/arch-system/borgbackup +++ b/arch-system/borgbackup @@ -2,39 +2,28 @@ set -o errexit -o errtrace -BORG_HOST="12390@ch-s012.rsync.net" -export BORG_REPO="$BORG_HOST:repos/$(hostname)" -export BORG_PASSPHRASE="$(< ~/.borg_secret)" -export BORG_RSH="ssh -o IdentitiesOnly=yes -o ConnectionAttempts=20 \ - -o ServerAliveInterval=30 -i ~/.ssh/borg_key" +source /etc/borg_env.sh + +export BORG_RSH="$BORG_RSH -o ConnectionAttempts=20 -o ServerAliveInterval=30" export LC_COLLATE=C -SNAPSHOT_TARGET="/.snapshots/home-$(date "+%Y-%m-%dT%H:%M:%S")" +SNAPSHOT_TARGET="/.snapshots/$SNAPSHOT_PREFIX-$(date "+%Y-%m-%dT%H:%M:%S")" cleanup() { cd / sudo -n /usr/bin/backup-sudo cleanup } -notify_user() { - if ! [ -t 1 ]; then - notify-send "$@" - fi -} - handle_failure() { notify_user -u critical "Backup failed!" echo "Backup failed!" >&2 - cleanup exit 2 } trap cleanup EXIT trap handle_failure INT TERM ERR -cleanup - backup() { # borg's caching of 'known' files is really dumb - it takes the full # canonical path to check if it has already seen a file. This means that the @@ -47,16 +36,18 @@ backup() { fi cd /backup + + BACKUP_TARGET="$SNAPSHOT_PREFIX"-"$(date -r . "+%Y-%m-%dT%H:%M:%S")" borg create --stats $borg_progress \ - --exclude-from ~/.borg_exclude \ + --patterns-from ~/.borg_pattern \ --timestamp . \ --show-rc \ - ::"$(basename "$1")" . && rc=$? || rc=$? + ::"$BACKUP_TARGET" . && rc=$? || rc=$? if [ $rc -eq 1 ]; then # borg defines return code 1 as warning, usually permission stuff notify_user "Warning: borgbackup returned 1. Check logs" elif [ $rc -gt 1 ]; then - borg list | grep -q "$(basename "$1")" || handle_failure + borg list --short | grep -q "$BACKUP_TARGET" || false fi cleanup @@ -64,21 +55,20 @@ backup() { } if [ ! -d "$SNAPSHOT_TARGET" ]; then - sudo -n backup-sudo snapshot "$SNAPSHOT_TARGET" + sudo -n backup-sudo snapshot "$SNAPSHOT_TARGET" "$SNAPSHOT_MOUNTPOINT" fi +cleanup + $BORG_RSH "$BORG_HOST" -f -N || rc=$? if [ ${rc-0} -eq 255 ]; then notify_user "Backup: upload skipped" echo "SSH server not reachable, skipping upload" >&2 exit 0 elif [ ${rc-0} -ne 0 ]; then - handle_failure + false fi -# break locks in case the previous run was interrupted -borg break-lock - for d in /.snapshots/*/ ; do echo "Now working on: $d" backup "$d" @@ -87,6 +77,7 @@ done echo "Pruning repository." borg prune --show-rc --list \ + --keep-last 20 \ --keep-hourly 72 \ --keep-daily 7 \ --keep-weekly 4 \ |