blob: 5cd0ef1c6da465649051c81dde0e9f00c18e8d9f (
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#!/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
REMOVE_ALL_BUT_N_FULL=4
REMOVE_OLDER_THAN=1Y
FULL_IF_OLDER_THAN=3M
source "$HOME/.duplicity.conf"
SOURCE=/
print_help() {
cat <<EOF
Commands:
backup run backup
cleanup cleanup
stats show collection status
list list files from backup
restore restore files from backup
Options:
--time|-t time specify the time from which to restore or list files
EOF
}
_duplicity() {
GNUPGHOME=/root/.gnupg nice ionice duplicity $DUPLICITY_OPTS "$@"
}
backup() {
_duplicity --exclude-filelist "$HOME/.duplicity-exclude" \
--full-if-older-than "$FULL_IF_OLDER_THAN" \
"$SOURCE" "$TARGET"
cleanup
}
cleanup() {
_duplicity cleanup --force "$TARGET"
_duplicity remove-all-but-n-full $REMOVE_ALL_BUT_N_FULL --force "$TARGET"
}
cleanup-old() {
_duplicity cleanup --force "$TARGET"
_duplicity remove-older-than $REMOVE_OLDER_THAN --force "$TARGET"
}
stats() {
_duplicity collection-status "$TARGET"
}
list() {
_duplicity list-current-files "$@" "$TARGET"
}
restore() {
_duplicity restore "$@" "$TARGET" "$(pwd)"
}
if [[ $# = 0 ]]; then
print_help
exit 0
fi
while (("$#")); do
case "$1" in
backup)
backup
;;
cleanup)
cleanup
;;
cleanup-old)
cleanup-old
;;
stats)
stats
;;
list)
shift
list "$@"
exit 0
;;
restore)
shift
restore "$@"
exit 0
;;
-h | --help | help)
print_help
;;
*)
shift
_duplicity "$@"
exit 0
;;
esac
shift
done
|