Re: Restoring selected records from backup file

From: Daniel Staal <DStaal(at)usa(dot)net>
To: Piyush Lenka <lenka(dot)piyush(at)gmail(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Restoring selected records from backup file
Date: 2012-03-03 01:04:40
Message-ID: 0BD1A802FC8596B3936A4B37@mac-pro.magehandbook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

--As of March 2, 2012 3:44:46 PM +0530, Piyush Lenka is alleged to have
said:

> hi,
>
> 1. How can we restore selected records from a plain text backup
> (backup.sql).
> 2. Is it possible using psql. If yes how

--As for the rest, it is mine.

A plain text backup will just be a set of SQL commands. You'll need to
isolate those commands that have the selected records, copy them out into a
new file, and then feed that file to psql.

If you are on a unix-like box, `grep` will be useful for this.

Note that there will probably be some SQL editing involved: the backup is
optimized for full-table restores, and therefore has multiple records per
statement, usually. (Depending on options specified at the backup creation
time: If you are expecting this to be a common type of restore, it might be
a good idea to use the `--inserts` or even `--column-inserts` switch.
Either will slow down a full restore considerably, but would make this type
of restore easy. See the docs for full details.)

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author. Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes. This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tareq Aljabban 2012-03-03 20:12:55 initDB - storage manager issues
Previous Message Brent Dombrowski 2012-03-02 22:34:47 Re: Data In Tables Sometimes Have +