blob: 5879c77fe6c5056860f5f2fc1efd4502365891fe (
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
|
#!/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
list list files from backup
restore restore files from backup
Options:
--time time specify the time from which to restore or list files
EOF
}
backup() {
duplicity cleanup --force "$TARGET"
duplicity remove-all-but-n-full 3 --force "$TARGET"
nice ionice duplicity \
--exclude-filelist "$HOME/.duplicity-exclude" \
--full-if-older-than 2M \
"$SOURCE" "$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
;;
stats)
stats
;;
list)
shift
list $*
exit 0
;;
restore)
shift
restore $*
exit 0
;;
*)
print_help
;;
esac
shift
done
|