Implemented automatic backup of mariadb (every 24 hours)

This commit is contained in:
Mascaro Lucas 2018-05-14 01:47:20 +02:00
parent 769d5ed9ba
commit 76712a2378
3 changed files with 25 additions and 3 deletions

View File

@ -83,4 +83,23 @@ docker exec php-fpm bash -c "cd /vhost; composer install" >/dev/null 2>&1 && ech
# 2. Re-build js/scss
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"

View File

@ -26,4 +26,7 @@ if [ -f $PID_FILE ]; then
else
echo "already";
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