Skip to content

Instantly share code, notes, and snippets.

@nelvson
Last active June 25, 2021 07:30
Show Gist options
  • Save nelvson/56188ab43c4e09b8bb11abd162629529 to your computer and use it in GitHub Desktop.
Save nelvson/56188ab43c4e09b8bb11abd162629529 to your computer and use it in GitHub Desktop.
Backup a postgres db on Docker
# backup both tables and data
docker exec -t CONTAINER pg_dumpall -c -U USERNAME > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
# backup data only
docker exec -t api_postgres_1 pg_dumpall -c -U prisma -a > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
# apply backup
cat your_dump.sql | docker exec -i CONTAINER psql -U USERNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment