Skip site navigation (1) Skip section navigation (2)

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: (view raw or whole thread)
Lists: pgsql-novice
--As of March 2, 2012 3:44:46 PM +0530, Piyush Lenka is alleged to have 

> 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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group