Add ability to backup and restore mysql database

This commit is contained in:
Alex Hyett 2015-12-19 22:31:06 +00:00
parent b98b84c3a6
commit 9636856edb
4 changed files with 15 additions and 1 deletions

View file

@ -14,4 +14,7 @@ mysql:
image: mysql:5.7 image: mysql:5.7
environment: environment:
- MYSQL_ROOT_PASSWORD=password - MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=wordpress - MYSQL_DATABASE=wordpress
volumes:
- /vagrant/data/:/docker-entrypoint-initdb.d
- /vagrant/scripts/:/scripts

View file

@ -0,0 +1,4 @@
#!/bin/bash
echo "Running docker-dbackup.sh"
/usr/bin/mysqldump -u root -p"$MYSQL_ROOT_PASSWORD" "$MYSQL_DATABASE" > /docker-entrypoint-initdb.d/dbbackup.sql
echo "Finished docker-dbackup.sh"

View file

@ -0,0 +1 @@
vagrant ssh -c "/vagrant/scripts/vagrant-dbbackup.sh"

View file

@ -0,0 +1,6 @@
#!/bin/bash
echo "Running vagrant-dbackup.sh"
ID="$(docker ps | grep mysql | awk -F ' ' '{print $1}')"
echo "mysql docker container is $ID"
docker exec -it $ID /scripts/docker-dbbackup.sh
echo "Finished vagrant-dbbackup.sh"