Re: copy a database

From: Christopher Browne <cbbrowne(at)acm(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: copy a database
Date: 2004-08-25 12:58:21
Message-ID: m3pt5f9xxu.fsf@wolfe.cbbrowne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In an attempt to throw the authorities off his trail, dsuela(at)xsto(dot)info (David Suela Fernández) transmitted:
> Is it possible to copy/migrate one database from one postgres server to
> other copying just the files in /var/lib/postgres/data/ ?
>
> I can't use pg_dump because it give me an error. I think than the
> instalation of postgres is corrupt because it give me a lot of error
> like "ERROR: relation "pg_catalog.pg_user" does not exist".

Copying files from a corrupted database will just get you a _second_
corrupt database.

If it's corrupted, then the best you can do is to get what data you
can out of the database, and put it into a NEW database.

What you might try would be to dump it table by table:

for table in this_table that_table other_table; do
pg_dump -p $SOURCEPORT -t $table $SOURCEDB | psql -p $NEWPORT $NEWDB
done

If the database is corrupted, that's likely to partly break, but I
doubt you'll do much better any other way.
--
If this was helpful, <http://svcs.affero.net/rm.php?r=cbbrowne> rate me
http://cbbrowne.com/info/lisp.html
"Natives who beat drums to drive off evil spirits are objects of scorn
to smart Americans who blow horns to break up traffic jams."
-- Unknown

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Deepa K 2004-08-25 13:32:51 IP clash in the PC
Previous Message David Suela Fernández 2004-08-25 12:35:48 copy a database