Skip to content

Instantly share code, notes, and snippets.

@nabucosound
Last active December 29, 2015 10:39
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 nabucosound/7658427 to your computer and use it in GitHub Desktop.
Save nabucosound/7658427 to your computer and use it in GitHub Desktop.

PostgreSQL Cheatsheet

Made by Nabuco (http://nomadblue.com/).

Note: Substitute [params] with the proper values.

Start server installed from Homebrew:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start -w

Backups

Dump a local database using the :

pg_dump -Fc --no-acl --no-owner -h localhost -U [dbuser] [dbname] > $(date "+myproject_%Y%m%d.pgdump")

Restore a backup file to local:

pg_restore -d [dbname] latest.pgdump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment