Skip to content

Instantly share code, notes, and snippets.

@avkosme
Last active November 18, 2019 11:27
Show Gist options
  • Select an option

  • Save avkosme/36e5d7ce197f0d100b47b9aae2158f31 to your computer and use it in GitHub Desktop.

Select an option

Save avkosme/36e5d7ce197f0d100b47b9aae2158f31 to your computer and use it in GitHub Desktop.
Postgres backup-restore
pg_dump -U postgres -O -Fc dbname > dumpfile
Here we used the following options:
-U to specify which user will connect to the PostgreSQL database server.
-W or --password will force pg_dump to prompt for a password before connecting to the server.
-F is used to specify the format of the output file, which can be one of the following:
p – plain-text SQL script
c – custom-format archive
d – directory-format archive
t – tar-format archive
pg_restore -U postgres -h localhost -d dbname dumpfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment