Backing up a PostgreSQL database from AppFog is as easy as typing two commands:
af login
af export-service [POSTGRESQL_DATABASE]
Restore using pg_restore
If you want to restore that backup in your localhost, then just execute the following command:
[YOUR_DUMP_FILE] is inside the file that you just downloaded when you exported the database.
These are the meanings of the flags used:
-c –clean Clean (drop) database objects before recreating them.
-d dbname –dbname=dbname Connect to database dbname and restore directly into the database.
-U username –username=username User name to connect as.
-W –password Force pg_restore to prompt for a password before connecting to a database.
You can read more documentation http://postgresql.org/docs/8.4/static/app-pgrestore.html
Restore on AppFog with pg_dump & pg_restore
PGPASSWORD=[LOCALHOST_PASSWORD] pg_dump -Fc –no-acl –no-owner -h localhost -U [LOCALHOST_USERNAME] [DEVELOPMENT_DB] > [DEVELOPMENT_DB].dump
Upload the .dump to your AppFog
RAILS_ENV=proxied-appfog pg_restore –verbose –clean –no-acl –no-owner -h localhost -p [PORT] -d [POSTGRESQL_DATABASE] -U [USERNAME] [DUMP_FILE]