pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Boes <jboes@nexcerpt.com>
To: pgsql-admin@postgresql.org
Subject: Re: HELP - need way to restore only blobs
Date: Wed, 18 Feb 2004 12:54:23 GMT
Message-ID: <c68c6dbaf66141ab10437a911f9f5a30@news.teranews.com> (raw)
References: <1077046844.5869.25.camel@localhost.localdomain>

At some point in time, wlittle@securitylending.com (Warren Little) wrote:

>I migrated my database from 7.3 to 7.4 this weekend using the pg_dumpall
>tool which I now realize does not capture blobs.
>
>I now need to move only the blob data to the 7.4 database.
>The problem with redoing the dump with pg_dump -b is the database is now
>in production and writing over the top of changes to the database is not
>exceptable.  The blob data is very static so if there was some way to
>copy the physical files from disk and modify some records in the system
>tables to properly locate the  blob records that would be best.  Another
>option I was looking at was to restore the archived database with the
>blobs intact and then restore the production version over the top
>without destroying the blob data.

In a similar situation, we wrote a script that constructs "\lo_export" commands
to dump each large object to a file. The file name for each contains the
information needed to reconstruct the object at the other end. For instance, if
you have a table like this:

CREATE TABLE foobar (primary_id INTEGER PRIMARY KEY, large_obj OID, ...)

you'd want a series of commands that look like this:

\lo_export <large_obj> <primary_id>.dmp

Then, given a directory full of such files, you construct another series of
commands that look like this:

\lo_import <primary_id>.dmp

UPDATE foobar SET large_obj = <new_value> WHERE primary_id = <primary_id>;

The trick is capturing the output of the \lo_import command and parsing it to
get the large object OID after it is created.

I don't know if I have permission to post or email the script, but if you
contact me offline I should know by then.

jboes at n/e/x/c/e/r/p/t/d/o/t/c/o/m

--
~~~~~~~~~~~~~~~~| Genius may have its limitations, but stupidity is not
Jeff Boes       | thus handicapped.
jboes@qtm.net   |        --Elbert Hubbard (1856-1915), American author





view thread (3+ messages)  latest in thread

Message-ID: <c68c6dbaf66141ab10437a911f9f5a30@news.teranews.com>
Permalink:  ../c68c6dbaf66141ab10437a911f9f5a30@news.teranews.com/
Also on:    postgresql.org/message-id/c68c6dbaf66141ab10437a911f9f5a30@news.teranews.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: jboes@nexcerpt.com
  Subject: Re: HELP - need way to restore only blobs
  In-Reply-To: <c68c6dbaf66141ab10437a911f9f5a30@news.teranews.com>
  References: <1077046844.5869.25.camel@localhost.localdomain> <c68c6dbaf66141ab10437a911f9f5a30@news.teranews.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