From a34abe3152f64881567ed39a49327fc1c81809f9 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 15 Jun 2020 15:47:00 +0200 Subject: update --- bin/byo | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 bin/byo (limited to 'bin/byo') 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" -- cgit v1.2.3