-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup_web.sh
70 lines (61 loc) · 1.34 KB
/
backup_web.sh
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
#!/bin/bash
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export PASSPHRASE=
# directories, space separated
SOURCE="/var/www"
BUCKET=s3+http://backet
LOGFILE=/home/------/duplicity.log
# set email to receive a backup report
EMAIL=""
backup() {
INCLUDE=""
for CDIR in $SOURCE
do
TMP=" --include ${CDIR}"
INCLUDE=${INCLUDE}${TMP}
done
# perform an incremental backup to root, include directories, exclude everything else, / as reference.
duplicity --full-if-older-than 30D $INCLUDE --exclude '**' / $BUCKET > $LOGFILE
if [ -n "$EMAIL" ]; then
mail -s "backup report" $EMAIL < $LOGFILE
fi
}
list() {
duplicity list-current-files $BUCKET
}
restore() {
if [ $# = 2 ]; then
duplicity restore --file-to-restore $1 $BUCKET $2
else
duplicity restore --file-to-restore $1 --time $2 $BUCKET $3
fi
}
status() {
duplicity collection-status $BUCKET
}
if [ "$1" = "backup" ]; then
backup
elif [ "$1" = "list" ]; then
list
elif [ "$1" = "restore" ]; then
if [ $# = 3 ]; then
restore $2 $3
else
restore $2 $3 $4
fi
elif [ "$1" = "status" ]; then
status
else
echo "
duptools - manage duplicity backup
USAGE:
./duptools.sh backup
./duptools.sh list
./duptools.sh status
./duptools.sh restore file [time] dest
"
fi
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export PASSPHRASE=