Skip to content

Instantly share code, notes, and snippets.

@nandiheath
Last active December 26, 2021 19:42
Show Gist options
  • Save nandiheath/a7c46440785d9c1e312f4f79285d46e9 to your computer and use it in GitHub Desktop.
Save nandiheath/a7c46440785d9c1e312f4f79285d46e9 to your computer and use it in GitHub Desktop.
PSQL commands
# psql dump table
source .env
pg_dump --host $POSTGRES_HOST --user $POSTGRES_USER --format custom --section data --on-conflict-do-nothing --inserts --file "$TABLE.sql" --table "$TABLE" $POSTGRES_DATABASE
# psql restore data
pg_restore -h 127.0.0.1 -U {user} -d {database} {table}.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment