-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackup.sh
More file actions
executable file
·29 lines (21 loc) · 809 Bytes
/
backup.sh
File metadata and controls
executable file
·29 lines (21 loc) · 809 Bytes
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
#!bash
# Created by Lee, Jun Seok <lego3410@gmail.com> at Jul 31, 2020
DIR=$(dirname $0)
DATE=$(date +%Y%m%d-%H%M)
BACKUPDIR=$DIR/backups/$DATE
source $DIR/.config
mkdir -p $BACKUPDIR
echo Creating a backup at $(date +"%Y.%m.%d %H:%M")
echo Backing up database into $BACKUPDIR/mysqldump.sql.gz...
# dump sql database from db container to a single compressed file
time docker-compose --project-directory $DIR \
exec db mysqldump \
-h localhost \
-u$MYSQL_USER \
-p$MYSQL_PASSWORD \
wiki | gzip > $BACKUPDIR/mysqldump.sql.gz 2> $BACKUPDIR/mysql.log
echo done.
echo Backing up images into $BACKUPDIR/images.tar.gz...
# copy images directory into a compressed file
time docker cp wiki_wiki_1:/var/www/html/images - | gzip > $BACKUPDIR/images.tar.gz 2> $BACKUPDIR/images.log
echo done.