Re: copy a database - Mailing list pgsql-general

From Christopher Browne
Subject Re: copy a database
Date
Msg-id m3pt5f9xxu.fsf@wolfe.cbbrowne.com
Whole thread Raw
In response to copy a database  (David Suela Fernández <dsuela@xsto.info>)
Responses Re: copy a database
List pgsql-general
In an attempt to throw the authorities off his trail, dsuela@xsto.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

pgsql-general by date:

Previous
From: David Suela Fernández
Date:
Subject: copy a database
Next
From: Mark Gibson
Date:
Subject: Re: Gentoo for production DB server?