blob: 173c2a731d382b42b922e387d318dc9d11378656 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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"
|