diff options
author | Karel Kočí <cynerd@email.cz> | 2020-03-30 11:15:35 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2020-03-30 11:15:35 +0200 |
commit | 107f1c0df4a95fc9f5a37f9a43484383ad9d5cf9 (patch) | |
tree | 974ac0fb38f598503c7793059e8ba946d2aea192 | |
parent | a60f3f16f61570fa792ff3a4131fb6b32ec08b87 (diff) | |
download | myconfigs-107f1c0df4a95fc9f5a37f9a43484383ad9d5cf9.tar.gz myconfigs-107f1c0df4a95fc9f5a37f9a43484383ad9d5cf9.tar.bz2 myconfigs-107f1c0df4a95fc9f5a37f9a43484383ad9d5cf9.zip |
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.
-rw-r--r-- | .ignore-cynerd-laptop | 1 | ||||
-rw-r--r-- | .ignore-cynerd-ridcully (renamed from .ignore-cynerd-desktop) | 1 | ||||
-rw-r--r-- | .ignore-cynerd-work | 1 | ||||
-rw-r--r-- | ignore-cynerd-onemix | 1 | ||||
-rwxr-xr-x | install | 4 | ||||
-rwxr-xr-x | local/bin/system-backup | 75 |
6 files changed, 0 insertions, 83 deletions
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-desktop b/.ignore-cynerd-ridcully index 1abe91e..56251be 100644 --- a/.ignore-cynerd-desktop +++ b/.ignore-cynerd-ridcully @@ -1,2 +1 @@ wake-desktop -backup 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 @@ -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" |