-
Notifications
You must be signed in to change notification settings - Fork 0
/
tds-backup.sh
49 lines (38 loc) · 1.33 KB
/
tds-backup.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
#!/bin/bash
#
# Simple script for creating backups with Duplicity.
# Full backups are made on the 1st day of each month or with the 'full' option.
# Incremental backups are made on any other days.
#
# USAGE: backup.sh [full]
#
# get day of the month
DATE=`date +%d`
# directories to backup (use . for /)
CONTAINERS="tds-drone tds-gitea tds-mailhog tds-portainer"
BDIRS="var/lib/docker/volumes/team-development-server_tds-gitea-data/ var/lib/docker/volumes/team-development-server_tds-portainer-data/"
TDIR="var/backup/volumes"
LOGDIR='/var/backup/log'
mkdir -p /$LOGDIR
mkdir -p /$TDIR
# Check to see if we're at the first of the month.
# If we are on the 1st day of the month, then run
# a full backup. If not, then run an incremental
# backup.
if [ $DATE = 01 ] || [ "$1" = 'full' ]; then
TYPE='full'
else
TYPE='incremental'
fi
for CONTAINER in $CONTAINERS
do
# if [ $CONTAINER = "tds-gitea" ]; then
#EXCLUDE="--exclude '/var/lib/docker/volumes/team-development-server_tds-gitea-data/_data/git/repositories'"
# fi
CMD="duplicity remove-older-than 2M -v5 --force file:///$TDIR/$CONTAINER >> $LOGDIR/$CONTAINER.log"
eval $CMD
# do a backup
CMD="duplicity $TYPE -v5 --no-encryption $EXCLUDE /var/lib/docker/volumes/team-development-server_$CONTAINER-data/ file:///$TDIR/$CONTAINER >> $LOGDIR/$CONTAINER.log"
eval $CMD
done
exit 0