Add ability to backup and restore mysql database
This commit is contained in:
parent
b98b84c3a6
commit
9636856edb
4 changed files with 15 additions and 1 deletions
|
@ -14,4 +14,7 @@ mysql:
|
|||
image: mysql:5.7
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=password
|
||||
- MYSQL_DATABASE=wordpress
|
||||
- MYSQL_DATABASE=wordpress
|
||||
volumes:
|
||||
- /vagrant/data/:/docker-entrypoint-initdb.d
|
||||
- /vagrant/scripts/:/scripts
|
||||
|
|
4
scripts/docker-dbbackup.sh
Normal file
4
scripts/docker-dbbackup.sh
Normal 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"
|
1
scripts/host-dbbackup.bat
Normal file
1
scripts/host-dbbackup.bat
Normal file
|
@ -0,0 +1 @@
|
|||
vagrant ssh -c "/vagrant/scripts/vagrant-dbbackup.sh"
|
6
scripts/vagrant-dbbackup.sh
Normal file
6
scripts/vagrant-dbbackup.sh
Normal 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"
|
Loading…
Reference in a new issue