Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RamsesMartinez/76004fe4b2399dec182018ac91c45dfd to your computer and use it in GitHub Desktop.
Save RamsesMartinez/76004fe4b2399dec182018ac91c45dfd to your computer and use it in GitHub Desktop.
Backup/restore postgres in docker container
Drop:
docker-compose exec db psql -U postgres -c "DROP DATABASE your-database"
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > 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