Skip to content

Instantly share code, notes, and snippets.

@shahanahmed86
Created August 7, 2023 12:26
Show Gist options
  • Save shahanahmed86/e8b16bf3e4bd8aea5e4cdbd01e043eae to your computer and use it in GitHub Desktop.
Save shahanahmed86/e8b16bf3e4bd8aea5e4cdbd01e043eae to your computer and use it in GitHub Desktop.
Backup and restore a postgres database from a running Docker container
# Backup
docker exec -t your-db-container pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
# Restore
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