Skip to content

Instantly share code, notes, and snippets.

@jeroneemou
Created March 13, 2019 16:56
Show Gist options
  • Save jeroneemou/1816a9a63b85ed05fdb1e809555f14cb to your computer and use it in GitHub Desktop.
Save jeroneemou/1816a9a63b85ed05fdb1e809555f14cb to your computer and use it in GitHub Desktop.
Backup and restore mysql docker container which has mounted volume for data
# Backup container of mysql
docker run --rm --volumes-from my-mysql-container -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /var/lib/mysql
# Restore container of mysql
docker run --rm --volumes-from my-mysql-container -v $(pwd):/backup ubuntu bash -c "cd /var && tar xvf /backup/backup.tar --strip 1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment