diff options
| author | Marc Vertes <mvertes@free.fr> | 2020-06-15 15:47:00 +0200 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2020-06-15 15:47:00 +0200 |
| commit | a34abe3152f64881567ed39a49327fc1c81809f9 (patch) | |
| tree | 72a96ccc4c291c3fc4bc65b40b6d0cd9467132a4 /bin/byo | |
| parent | be6b10671bf77dcc6e2fba829cef11c800652880 (diff) | |
update
Diffstat (limited to 'bin/byo')
| -rwxr-xr-x | bin/byo | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -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" |
