From 76e0da0ef07a921e27b12a447692d1e952d922f4 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Sat, 11 Jul 2020 14:11:07 +0200 Subject: Spring cleaning --- backup/backup.sh | 75 ----------------------------- backup/systemd/max-backup@.service | 8 --- backup/udev/rules.d/99-max-autobackup.rules | 2 - 3 files changed, 85 deletions(-) delete mode 100755 backup/backup.sh delete mode 100644 backup/systemd/max-backup@.service delete mode 100644 backup/udev/rules.d/99-max-autobackup.rules (limited to 'backup') diff --git a/backup/backup.sh b/backup/backup.sh deleted file mode 100755 index 91acdfc..0000000 --- a/backup/backup.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/bash -logger "================================================================================" - -# BACKUP_NAME=$ID_SERIAL-part$ID_PART_ENTRY_NUMBER -BACKUP_NAME=$(echo $1 | sed -e 's/\\x2d/-/g') -MOUNT_TARGET=/media/$BACKUP_NAME - -function fail() { - logger -s -t "$0" "Backup '$1' -> '$2' failed." - sudo -u max beep -f 40 -l 500 - # sudo -u max beep -f 523 -l 150 -n -f 54 -l 600 -} - -function start() { - DEVNAME=$(echo $1 | sed 's/-/\\x2d/') - systemctl restart media-$DEVNAME.automount - - logger -t "$0" "Backup '$1' -> '$2' started." - sudo -u max beep -f 147 -l 120 -n -f 294 -l 200 -n -f 831 -} - -function stop() { - DEVNAME=$(echo $1 | sed 's/-/\\x2d/') - systemctl stop media-$DEVNAME.automount - - logger -t "$0" "Backup '$1' -> '$2' finished." - sudo -u max beep -f 831 -l 120 -n -f 294 -l 200 -n -f 147 -} - -function zfs_snapshot() { - zfs diff $LAST_SNAPSHOT > $ZFS_PATH/backup-differences.txt - zfs snap media-backup/$BACKUP_NAME@$(date +%Y-%m-%d--%H-%M) - echo "Here comes a list of changes since your last backup: $LAST_SNAPSHOT" | mailx -A typesafe -a $ZFS_PATH/backup-differences.txt -s 'Backup overview' max@entwicklerseite.de -} - -start $1 - -if ! findmnt $MOUNT_TARGET; then - logger "$MOUNT_TARGET is not mounted. Cannot back it up." - exit 0 -fi - -logger ">> Inspecting $BACKUP_NAME" -ZFS_PATH=$(zfs get mountpoint -H -o value media-backup/$BACKUP_NAME) || fail "$MOUNT_TARGET" "(no zfs dataset found)" -ZFS_MOUNTPATH=$(findmnt -no source $ZFS_PATH) || fail "$ZFS_PATH (not mounted)" "(no association)" -LAST_SNAPSHOT=$(zfs list -t snap -o name -s creation media-backup/$BACKUP_NAME | tail -n1) - - -# Make sure, that we are really writing where a mountpoint is -if [ "$ZFS_PATH" == "/$ZFS_MOUNTPATH" ]; then - sudo -u max beep -f 831 - logger "We can start $MOUNT_TARGET -> $ZFS_PATH" - rsync -ahoi -x --delete --info=all \ - "/media/$BACKUP_NAME/" \ - "$ZFS_PATH" \ - 2>&1 | tee $ZFS_PATH/backup-report.txt && zfs_snapshot - -else - fail $ZFS_PATH $ZFS_MOUNTPATH - exit 1 -fi - - - -stop $1 - -# sleep a second so that /dev/disk/by-id/*-part become available -# sleep 1 - -# DISK=$(readlink -f /dev/disk/by-id/$ID_BUS-$ID_SERIAL) -# if ! [ -e "$DISK" ]; then -# fail -# logger "$DISK: Disk not there :(" -# exit 1 -# fi diff --git a/backup/systemd/max-backup@.service b/backup/systemd/max-backup@.service deleted file mode 100644 index 44c6bf8..0000000 --- a/backup/systemd/max-backup@.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=Generic backup - -[Service] -Type=simple -ExecStart=/home/max/backup/backup.sh %I - - diff --git a/backup/udev/rules.d/99-max-autobackup.rules b/backup/udev/rules.d/99-max-autobackup.rules deleted file mode 100644 index e17bba0..0000000 --- a/backup/udev/rules.d/99-max-autobackup.rules +++ /dev/null @@ -1,2 +0,0 @@ -ACTION=="add", ENV{ID_PART_ENTRY_NUMBER}=="[0-9]", ENV{SYSTEMD_WANTS}="max-backup@$env{ID_SERIAL}\\x2dpart$env{ID_PART_ENTRY_NUMBER}.service" -LABEL="External disk drive backup" -- cgit v1.2.3