Skip to content

Instantly share code, notes, and snippets.

@neophiliac
Created January 31, 2018 18:45
Show Gist options
  • Select an option

  • Save neophiliac/3b2b237b93804187c53193952b00416b to your computer and use it in GitHub Desktop.

Select an option

Save neophiliac/3b2b237b93804187c53193952b00416b to your computer and use it in GitHub Desktop.
simple backup script for docker database container - to be run from cron
#!/bin/sh
cd ~/backups
MYSQL_CONTAINER_ID=`(docker ps | grep mysql | awk '{print $1}')`
NOW=`date "+%Y-%m-%dT%H_%M_%S"`
docker exec $MYSQL_CONTAINER_ID /usr/bin/mysqldump -u root --password=3dodPaTXF5 --opt mediawiki > backup_$NOW.sql
#this assumes that there is only one mysql container and that it has 'mysql' in its name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment