pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shane Ambler <pgsql@007Marketing.com>
To: Duncan McDonald <duncan@gpats.com.au>
Cc: pgsql-admin@postgresql.org
Subject: Re: Backing Up Partial Databases
Date: Thu, 26 Oct 2006 16:08:05 +0930
Message-ID: <454057CD.5030401@007Marketing.com> (raw)
In-Reply-To: <018701c6f8ac$0ad93bf0$2102a8c0@Firefly>
References: <018701c6f8ac$0ad93bf0$2102a8c0@Firefly>

Duncan McDonald wrote:
> Hi All,
> 
> I was wondering whether there was a way to back up partial sets of data 
> as INSERT statements? Pg_dump seems only to handle whole databases or 
> tables.
> 
> I have two identical databases (primary and backup) and I need to 
> transfer a small portion of missing data from one to the other. Is there 
> an easier way to do this rather than SELECT-ing the interval then 
> parsing the ouput to look like INSERT statements?
> 

I can think of a couple of ways -

COPY (SELECT * FROM myPrimaryTable WHERE id<200) TO '/tmp/myData';

you can then

COPY myBackupTable FROM '/tmp/myData';


Another option is to create a table to hold the selected rows then
SELECT * INTO myTempTable FROM myPrimaryTable WHERE id<200;

then use pg_dump --table=myTempTable > /tmp/myData

the --inserts option of pg_dump will export as INSERT's if that is the 
way you want to do it. You will need to do a find and replace on the 
INSERT's to change the table name though.


-- 

Shane Ambler
pgSQL@007Marketing.com

Get Sheeky @ http://Sheeky.Biz



view thread (3+ messages)  latest in thread

Message-ID: <454057CD.5030401@007Marketing.com>
Permalink:  ../454057CD.5030401@007Marketing.com/
Also on:    postgresql.org/message-id/454057CD.5030401@007Marketing.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: pgsql@007Marketing.com, duncan@gpats.com.au
  Subject: Re: Backing Up Partial Databases
  In-Reply-To: <454057CD.5030401@007Marketing.com>
  References: <018701c6f8ac$0ad93bf0$2102a8c0@Firefly> <454057CD.5030401@007Marketing.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox