Skip to content

Instantly share code, notes, and snippets.

@Hotfirenet
Last active March 19, 2018 10:18
Show Gist options
  • Save Hotfirenet/7dbe933de6cf259e6319faf3f54e505d to your computer and use it in GitHub Desktop.
Save Hotfirenet/7dbe933de6cf259e6319faf3f54e505d to your computer and use it in GitHub Desktop.
Use this shell to backup your docker mysql databases
#!/bin/sh
date=$(date +%y-%m-%d)
bckdir=REPLACE
keep_day=2
container=REPLACE
docker exec -ti ${container} mysqldump --login-path=local --single-transaction --all-databases | gzip > "${bckdir}/${container}_${date}.sql.gz
find "${bckdir}"/* -mtime +${keep_day} -exec rm {} \;
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment