Skip to content

Instantly share code, notes, and snippets.

View GauSim's full-sized avatar

Simon Gausmann GauSim

View GitHub Profile
@GauSim
GauSim / postgres-cheatsheet.md
Created November 16, 2021 18:51 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@GauSim
GauSim / gist:ecff85b28f7c82eadaabb354bd28c7c2
Created November 16, 2021 18:47 — forked from dirkgroenen/gist:07c3e8e4bc7e08bc3232ae0bdd6a0ba5
Backup Heroku Postgres database and restore to local database

Grab new backup of database

Command: heroku pgbackups:capture --remote production

Response: >>> HEROKU_POSTGRESQL_COLOR_URL (DATABASE_URL) ----backup---> a712

Get url of backup download

Command: heroku pgbackups:url [db_key] --remote production