Skip to content

Instantly share code, notes, and snippets.

@Rofram
Created April 28, 2022 16:18
Show Gist options
  • Save Rofram/f03a5429ca5e6129d2d13e1c6a573b69 to your computer and use it in GitHub Desktop.
Save Rofram/f03a5429ca5e6129d2d13e1c6a573b69 to your computer and use it in GitHub Desktop.
Backup/Restore Docker Postgres

Backup your databases

docker exec -t your-db-container pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql

Restore your databases

cat your_dump.sql | docker exec -i your-db-container psql -U postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment