Skip to content

Instantly share code, notes, and snippets.

@mkyung
Forked from nepsilon/pg-backup.md
Created June 7, 2016 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkyung/c10dc86b4476b0c3cc54a7c2659cb81c to your computer and use it in GitHub Desktop.
Save mkyung/c10dc86b4476b0c3cc54a7c2659cb81c to your computer and use it in GitHub Desktop.
Proper way to do backup (and restore!) with PostgreSQL 🐘
# Backup your database with:
# This is Postgres custom format
pg_dump -Fc dbname > filename
# And recover it with:
# First create the DB with:
createdb -O owner_user dbname
# And then populate it:
pg_restore -d dbname filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment