PostgreSQL portage: move table data from one server to another

Using the pg_dump command you can export individual table data and import to another server. I've found this useful for exporting data from a development database's tables to a staging server, all from the local development machine. To dump a table from the dev database:

1
$ pg_dump -h devserv djangodb -U postgres -a -t lookup_table -f devserv_djangodb_lookup_table.sql
Where:
  • -h is the host
  • -U is the user
  • -a skip the schema, just dump the data
  • -t is the table name
  • -f is the output file

The -i flag skips version mismatch between server and psql client if you need it To import the data into the staging db:

1
$ psql -h db.example.com djangodb postgres < rootadunits.sql