-
Notifications
You must be signed in to change notification settings - Fork 37
Managing overview on amazon
adamhooper edited this page Jan 28, 2013
·
29 revisions
-
overview-manage ssh production database
to log in to thedatabase
instance sudo -u postgres psql overview
This works even while the database is being modified. The backed-up database will have the exact same state as the database had when the backup started.
If you're backing up a database from a remote Postgres server:
- Find the host, username, database and password of the database to back up.
-
pg_dump -v --no-owner -Fc -f backup.psql --host HOST --user USERNAME DATABASE
and enter the password.
But if you're logged into the database
instance, it's easier (as long as you're in a directory with the right permissions):
sudo -u postgres pg_dump -v --no-owner -Fc -f backup.psql
(The --no-owner
is necessary when backing up from Heroku, because the Heroku username, which is gibberish, won't exist on our Amazon AWS server and so the restore will fail.)
- Run
DROP SCHEMA public CASCADE; CREATE SCHEMA public;
in a database shell. - Run
sudo -u postgres pg_restore -v -f BACKUP-FILENAME DATABASE