Implemented automatic backup of mariadb (every 24 hours)
This commit is contained in:
parent
769d5ed9ba
commit
76712a2378
|
@ -84,3 +84,22 @@ docker exec php-fpm bash -c "cd /vhost; composer install" >/dev/null 2>&1 && ech
|
||||||
# 2. Re-build js/scss
|
# 2. Re-build js/scss
|
||||||
echo -n " * Webpack build.............";
|
echo -n " * Webpack build.............";
|
||||||
docker exec php-fpm bash -c "cd /vhost; npm install; npm run build" >/dev/null 2>&1 && echo "built" || (echo "failed"; exit 1);
|
docker exec php-fpm bash -c "cd /vhost; npm install; npm run build" >/dev/null 2>&1 && echo "built" || (echo "failed"; exit 1);
|
||||||
|
|
||||||
|
# 3. touch the file the backup loop will use to run
|
||||||
|
echo -n " * Launch mariadb backup loop.............";
|
||||||
|
|
||||||
|
backup(){
|
||||||
|
if [ ! -d $ROOT/backups ]; then
|
||||||
|
mkdir $ROOT/backups;
|
||||||
|
fi
|
||||||
|
|
||||||
|
touch $ROOT/backuploop
|
||||||
|
while [ -f $ROOT/backuploop ]; do
|
||||||
|
# sleep 24 hours before next backup kick in
|
||||||
|
sleep 86400;
|
||||||
|
docker exec $MARIADB_SERVICE mysqldump --all-databases --flush-privileges -uroot -p$MARIADB_ROOT_PASSWORD | gzip > $ROOT/backups/$(date -d "today" +"%Y%m%d%H%M").sql.gz;
|
||||||
|
done;
|
||||||
|
}
|
||||||
|
|
||||||
|
backup &;
|
||||||
|
echo "done"
|
||||||
|
|
|
@ -27,3 +27,6 @@ else
|
||||||
echo "already";
|
echo "already";
|
||||||
fi;
|
fi;
|
||||||
rm $PID_FILE >/dev/null 2>&1;
|
rm $PID_FILE >/dev/null 2>&1;
|
||||||
|
|
||||||
|
echo -ne " * Kill backup loop............";
|
||||||
|
rm $ROOT/backuploop && echo "killed" || (echo "fail"; exit 1);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 32da5131b4c203bc0495f980a2d1cfc3ec15423c
|
Subproject commit 8f909821b6fea274722e0662d2863de2e1b0cd59
|
Loading…
Reference in New Issue