-
Notifications
You must be signed in to change notification settings - Fork 0
/
tds-restore.sh
47 lines (41 loc) · 1.12 KB
/
tds-restore.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
#!/bin/bash
usage(){
echo "USAGE:
`basename $0` [options]
Options:
-t, --time TIME specify the time from which to restore or list files
"
}
while getopts ":c:t:bfvlsnd-:" opt; do
case $opt in
c) CONFIG=$OPTARG;; # set the config file from the command line
t) TIME=$OPTARG;; # set the restore time from the command line
:)
echo "Option -$OPTARG requires an argument." >&2
COMMAND=""
;;
\?)
echo "Invalid option: -$OPTARG" >&2
COMMAND=""
;;
esac
done
# directories to backup (use . for /)
CONTAINERS="tds-drone tds-gitea tds-mailhog tds-portainer"
BDIRS="var/backup/volumes"
TDIR="var/backup/restore"
LOGDIR='/var/backup/log'
mkdir -p /$TDIR
for CONTAINER in $CONTAINERS
do
if [ ! -z "$TIME" ]; then
STATIC_OPTIONS="--time $TIME"
rm -rf /$TDIR/restore/$TIME/$CONTAINER
CMD="duplicity restore $STATIC_OPTIONS --no-encryption file:///$BDIRS/$CONTAINER /$TDIR/$TIME/$CONTAINER"
else
rm -rf /$TDIR/restore/last/$CONTAINER
CMD="duplicity restore --no-encryption file:///$BDIRS/$CONTAINER /$TDIR/last/$CONTAINER"
fi
eval $CMD
done
exit 0