Re: restore a table in a database

From: val <valiouk(at)yahoo(dot)co(dot)uk>
To: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>, Marc Fromm <Marc(dot)Fromm(at)wwu(dot)edu>
Subject: Re: restore a table in a database
Date: 2008-12-04 13:56:40
Message-ID: 897635.17316.qm@web25804.mail.ukl.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

--- On Wed, 3/12/08, Marc Fromm <Marc(dot)Fromm(at)wwu(dot)edu> wrote:

> From: Marc Fromm <Marc(dot)Fromm(at)wwu(dot)edu>
> Subject: [ADMIN] restore a table in a database
> To: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
> Date: Wednesday, 3 December, 2008, 7:21 PM
> How do I restore just a table to a database? I was able to
> create a backup of the required table from a backup of the
> database as follows.
> I don't know how to properly restore the backed up
> table "departments" to the original
> "sms" database.
>
> create a new db
> createdb -U postgres smstest
>
> restore a backup of the db to the new db
> psql -U postgres smstest <
> /tmp/postgresql-sms-11-24-2008_04-05-database
>
> backup up the specific table from the restored db
> pg_dump -U postgres -a -t departments smstest >
> /tmp/smsdepartments
>
> The table backup is smsdepartments. How do I restore
> smsdepartments to the table called departments in the sms
> database?
>
> Thanks
>
> Marc

Open up the backup file and change the tablename in the CREATE and COPY commands from smsdepartments to departments. Then restore with:
psql -U postgres smstest < /tmp/smsdepartments

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Marlowe 2008-12-04 14:15:46 Re: autovacuum benchmarking ...
Previous Message news 2008-12-04 00:10:45 Problem solving e decision making