summaryrefslogtreecommitdiff
path: root/bin/byo
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2020-06-15 15:47:00 +0200
committerMarc Vertes <mvertes@free.fr>2020-06-15 15:47:00 +0200
commita34abe3152f64881567ed39a49327fc1c81809f9 (patch)
tree72a96ccc4c291c3fc4bc65b40b6d0cd9467132a4 /bin/byo
parentbe6b10671bf77dcc6e2fba829cef11c800652880 (diff)
update
Diffstat (limited to 'bin/byo')
-rwxr-xr-xbin/byo34
1 files changed, 34 insertions, 0 deletions
diff --git a/bin/byo b/bin/byo
new file mode 100755
index 0000000..173c2a7
--- /dev/null
+++ b/bin/byo
@@ -0,0 +1,34 @@
+#!/bin/sh -e
+# Backup to yoda
+[ "$USER" = root ] || exec sudo "$0" "$@"
+
+usage='Usage: byo [-cdk]
+Backup local disk to yoda external disk.
+
+Options:
+ -c close and umount yoda
+ -d dedupe yoda
+ -k do not umount and close yoda
+'
+
+while getopts :cdk opt; do
+ case $opt in
+ (c|d|k) eval "opt$opt=$opt" ;;
+ (*) printf %s "$usage"; exit 1 ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+yoda_uuid='8c463221-6bb7-414e-9060-c9570bb3a6bb'
+
+dest=/mnt/backup/$(hostname)
+[ -b /dev/mapper/yoda ] && noclose=1 || cryptsetup open "$(blkid --uuid "$yoda_uuid")" yoda
+findmnt /dev/mapper/yoda /mnt >/dev/null && noumount=1 || mount /dev/mapper/yoda /mnt
+time backup -Fv "$dest"
+backup-clean -v "$dest"
+[ ! "$optd" ] || time duperemove -drh --hashfile="$dest/.hashfile" "$dest"
+[ ! "$optk" ] || noumount=1 noclose=1
+[ ! "$optc" ] || noumount='' noclose=''
+[ "$noumount" ] || umount /mnt
+[ "$noclose" ] || cryptsetup close yoda
+echo "bye"