Skip to content

Instantly share code, notes, and snippets.

@kkkasio
Last active August 5, 2021 12:17
Show Gist options
  • Save kkkasio/9ce5d6f704c246af0504b3970ab1611e to your computer and use it in GitHub Desktop.
Save kkkasio/9ce5d6f704c246af0504b3970ab1611e to your computer and use it in GitHub Desktop.
Backup specifc database
docker exec -i database pg_dump --u postgres DATABASE_NAME_HERE > DUMP_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Backup all databases
docker exec -t -u postgres CONTAINER_NAME_HERE pg_dumpall -c > DUMP_`date +%d-%m-%Y"_"%H_%M_%S`.sql
to restore:
cat YOUR_FILE.sql | docker exec -i CONTAINER_NAME_HERE psql -U USER_NAME_HERE -d DATABASE_NAME_HERE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment