Postgres Notes

Remotely connecting to Postgres instance using psql command

If you want to remotely connect to a Postgres instance. You can use this command

psql -h <REMOTE HOST> -p <REMOTE PORT> -U <DB_USER> <DB_NAME>

How to Back Up Your PostgreSQL Database

pg_dump -h <REMOTE HOST> -p <REMOTE PORT> -U <USERNAME> <DATABASE> > ~/Documents/filename.sql

How to Restore Your PostgreSQL Database

psql -U postgres <DATABASE> < <FILENAME>

Leave a Comment