From 107f1c0df4a95fc9f5a37f9a43484383ad9d5cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Mon, 30 Mar 2020 11:15:35 +0200 Subject: Drop system backup script I am not using backups anymore as I have data synchronized across systems and those can be recovered from any PC now. --- .ignore-cynerd-desktop | 2 -- .ignore-cynerd-laptop | 1 - .ignore-cynerd-ridcully | 1 + .ignore-cynerd-work | 1 - ignore-cynerd-onemix | 1 - install | 4 --- local/bin/system-backup | 75 ------------------------------------------------- 7 files changed, 1 insertion(+), 84 deletions(-) delete mode 100644 .ignore-cynerd-desktop delete mode 100644 .ignore-cynerd-laptop create mode 100644 .ignore-cynerd-ridcully delete mode 100644 .ignore-cynerd-work delete mode 100644 ignore-cynerd-onemix delete mode 100755 local/bin/system-backup diff --git a/.ignore-cynerd-desktop b/.ignore-cynerd-desktop deleted file mode 100644 index 1abe91e..0000000 --- a/.ignore-cynerd-desktop +++ /dev/null @@ -1,2 +0,0 @@ -wake-desktop -backup diff --git a/.ignore-cynerd-laptop b/.ignore-cynerd-laptop deleted file mode 100644 index ec76ec2..0000000 --- a/.ignore-cynerd-laptop +++ /dev/null @@ -1 +0,0 @@ -backup diff --git a/.ignore-cynerd-ridcully b/.ignore-cynerd-ridcully new file mode 100644 index 0000000..56251be --- /dev/null +++ b/.ignore-cynerd-ridcully @@ -0,0 +1 @@ +wake-desktop diff --git a/.ignore-cynerd-work b/.ignore-cynerd-work deleted file mode 100644 index ec76ec2..0000000 --- a/.ignore-cynerd-work +++ /dev/null @@ -1 +0,0 @@ -backup diff --git a/ignore-cynerd-onemix b/ignore-cynerd-onemix deleted file mode 100644 index ec76ec2..0000000 --- a/ignore-cynerd-onemix +++ /dev/null @@ -1 +0,0 @@ -backup diff --git a/install b/install index 2ee2765..1ff6c4d 100755 --- a/install +++ b/install @@ -124,7 +124,3 @@ fi if ask "wake-desktop" "Install wake-desktop"; then inst local/bin/wake-desktop ~/.local/bin/wake-desktop fi - -if ask "backup" "Install backup script"; then - inst local/bin/system-backup ~/.local/bin/system-backup -fi diff --git a/local/bin/system-backup b/local/bin/system-backup deleted file mode 100755 index dfa2c09..0000000 --- a/local/bin/system-backup +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# vim:ft=sh -# New line separated list of all directories to backup -DIRS="/etc -/home -/home_hdd" -# Name of the machine used in backup subvolumes -MNAME=asus -# Path where backup will be mounted -MPATH=/media/backup -# UUID of disk -UUID=b162ea95-38bb-42c6-b36a-1be98c65392c -# Mount additional arguments -MARGS="-o compress=lzo" -# If disk is encrypted -CRYPT=true -#################################################################### -# Check if running as root -if [ `id -u` -ne "0" ]; then - echo Please run this as root. - exit 1 -fi -set -e - -# Mount disk -PART=$(lsblk -fpl | grep "$UUID" | awk '{print $1}') -if [ -z "$PART" ]; then - echo Disk not detected. Exiting - exit -1 -fi -if $CRYPT; then - echo -e "\e[1;33mDecrypting filesystem\e[0m" - # TODO what if already opened - cryptsetup open "$PART" backup || (echo Decryption failed && exit -2) - PART=/dev/mapper/backup - echo $PART -fi -echo -e "\e[1;33mMounting\e[0m" -mkdir -p "$MPATH" -mount $MARGS "$PART" "$MPATH" || (echo Mount failed && exit -3) - -[ -d "$MPATH"/@"$MNAME" ] || (echo There seems to be no subvolume $MNAME && exit -4) - -# Do backup -while read -r DIR; do - echo -e "\e[1;33mBacking up: $DIR\e[0m" - rsync -aAxXS --delete --progress "$DIR" "$MPATH"/@"$MNAME"/ || [ $? -eq 24 ] - # We ignore exit code if rsync detects vanished source file -done <<< "$DIRS" - -# Do snapshot (read only) -(cd "$MPATH"; btrfs subvolume snapshot -r @asus @asus-$(date -u +%y%m%d)) - -# Remove snapshots older than 2 months -# TODO ensure that at least five stays -(cd "$MPATH" -for s in @"$MNAME"-*; do - if [ $(expr $(date +%s) - $(stat -c %Y "$s")) -gt 5529600 ]; then - btrfs subvolume delete "$s" - fi -done) - -# Unmount disk -sync -f "$MPATH"/@"$MNAME" -umount "$MPATH" || (echo Unmount failed. Unmount by hand. && exit -5) -if $CRYPT; then - cryptsetup close backup || (echo Encryption close failed. Do by hand. && exit -6) -fi - -# Store when we did last backup and update i3blocks status -date +"%s" > /home/cynerd/.backup_date -pkill -RTMIN+13 i3blocks - -echo -echo -e "\e[1;34mBackup finished\e[0m" -- cgit v1.2.3