Skip to content

Instantly share code, notes, and snippets.

@amille44420
Last active November 29, 2018 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amille44420/bc1e917caca2723b10e7618c97c6b039 to your computer and use it in GitHub Desktop.
Save amille44420/bc1e917caca2723b10e7618c97c6b039 to your computer and use it in GitHub Desktop.

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