How to migrate BLOBS between DB with less steps???

From: Evelio Martínez <evelio(dot)martinez(at)testanet(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: How to migrate BLOBS between DB with less steps???
Date: 2001-11-08 19:18:18
Message-ID: 015301c1688a$1fcba5a0$4ecd72c3@testanet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hello all!

I would like to know if there is a more simple way to migrate BLOB between diferent databases?
I have done it in 7 steps:

1. Export source database
pg_dump -o DB1 > /tmp/DB1.sql

2. Create target database

psql DB1

> create database db2

3. Change to source DB and export OID naming them with the primary key.

\c DB1
select lo_export(proy_foto.foto,'/tmp/fotos/' || numero ) from proy_foto;

4. Create target DB as a copy of source DB.

psql DB2 < /tmp/DB1.sql

5. Change to target DB.
\c DB2

6. Create a temp table with just 1 column ( the primary key of source table) in order to make an special update later.

create temp table kk as select numero from proy_foto;

7. Update BLOB column en target DB with the previous exported rows from source DB.

update proy_foto set foto = lo_import('/tmp/fotos/' || proy_foto.numero) from kk where kk.numero=proy_foto.numero;

------------
Evelio Martínez
Testanet. Dept. desarrollo software.
Av. Reino de Valencia, 15 - 5
46005 Valencia (Spain)
Tel: +34 96 395 90 00
Fax: +34 96 316 23 19
http://www.testanet.com

Browse pgsql-general by date

  From Date Subject
Next Message Richard Teviotdale 2001-11-08 19:41:39 Re: searching multiple tables and databases
Previous Message Stephan Szabo 2001-11-08 19:18:00 Re: Problem with function