Skip to content

Instantly share code, notes, and snippets.

@rgpower
Created April 30, 2022 17:08
Show Gist options
  • Save rgpower/5ddcff08c47aa762d1a66b19236db5db to your computer and use it in GitHub Desktop.
Save rgpower/5ddcff08c47aa762d1a66b19236db5db to your computer and use it in GitHub Desktop.
Postgres (PG) Backup and Restore: pg_dump and pg_restore usage
# backup
pg_dump -v -Fd -U $USER -f $DUMP_DIR $DB
# restore, doing required drops beforehand to avoid most constraint errors
pg_restore --verbose --clean --no-acl --no-owner -Fd -U $USER -d $DB $DUMP_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment