Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

PostgreSQL

Backup

docker exec -u <your_postgres_user> <postgres_container_name> pg_dump -Fc <database_name_here> > db.dump

Restore

docker exec -i -u <your_postgres_user> <postgres_container_name> pg_restore -C -d <database_name_here> < db.dump

MySQL

Backup

docker exec <postgres_container_name> /usr/bin/mysqldump -u <mysql_user> --password=<mysql_password> <database_name_here> > backup.sql

Restore

cat backup.sql | docker exec -i <postgres_container_name> /usr/bin/mysql -u <mysql_user> --password=<mysql_password> DATABASE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment