summaryrefslogtreecommitdiff
path: root/d-backup
blob: 090b672e3b31fe2ab276431bb5b927780a7c34f5 (plain) (blame)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
#
# Example content of duplicity.conf, keep file root:root and only owner 0600
# ---------------- 8< --------------------
# FTP_PASSWORD="ftp_password"
# PASSPHRASE="passphrase"
# TARGET="sftp://server/path"
# ---------------- 8< --------------------

if [ ! $(whoami) = root ] ; then
    echo "This script must be run by the user: root"
    exit 1
fi

HOME=/home/anton

source "$HOME/.duplicity.conf"
SOURCE=/

print_help() {
    cat <<EOF
Commands:
  backup  run backup
  stats   show collection status
EOF
}

backup() {
    duplicity cleanup --force "$TARGET"
    duplicity \
        --exclude-filelist "$HOME/.duplicity-exclude" \
        --full-if-older-than 2M \
        "$SOURCE" "$TARGET"
}

stats() {
    duplicity collection-status "$TARGET"
}

if [[ $# = 0 ]] ; then
    print_help
    exit 0
fi

while (( "$#" )) ; do
    case "$1" in
        backup)
            backup
            ;;
        stats)
            stats
            ;;
        *)
            print_help
            ;;
    esac
    shift
done