Backing Up Postgresql Tables One at a Time

How to backup a single postgresql table with pg_dump

Here are the commands I found to work best in postgresql version 8.4:

commands to copy tables to /home/raid temp
#change dir to tmp:
cd /tmp
#change user to postgres
su postgres
#enter password:
#enter the following sql command replacing did_serial with actual table name:
pg_dump -a -t did_serial -f did_serial.sql maximize_master

 

One Reply to “Backing Up Postgresql Tables One at a Time”

  1. Then you can restore the table with:
    psql database_name < table_name.sql but if you are going from an old version of postgresql to a new version, you will have to edit the sql file by taking out all the commands before the first copy statement.

Leave a Reply

Your email address will not be published. Required fields are marked *