Re: Restoring databases using only data/ dir - Mailing list pgsql-general

From Afra
Subject Re: Restoring databases using only data/ dir
Date
Msg-id 3D9CAA6F.5000409@cse.buffalo.edu
Whole thread Raw
In response to Restoring databases using only data/ dir  (Afra <aa4@cse.buffalo.edu>)
Responses Re: Restoring databases using only data/ dir  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi,

Thank you for the quick reply. Here is a more detailed account of what
is happening...

Well, we were hosting our Postgres boxes at a co-host place. The machine
crashed and has no dumps of any databases on there. However, luckily, I
do have a tar backup of the pgsql directory, which contains all the
files in data/.

Now, the old server was running postgres 7.1. So I installed the same
version in house and moved over the data/ directory from the backup tar
file to the newly build data directory:

# mv backup/pgsql/data/global /usr/local/psql/data/
# mv backup/pgsql/data/base /usr/local/psql/data/
# mv backup/pgsql/data/pg_xlog /usr/local/psql/data
# su - postgres

Postgres starts up fine after the move, but then I cannot actually
retrieve any databases:

$ pg_dump wdcx > wdcx
pg_dump: couldn't find the pg_database entry.
There is no entry in the 'pg_database' table for this database.

Odd thing is, the database is in there and Postgres knows it:

$ createdb wdcx
ERROR:  CREATE DATABASE: database "wdcx" already exists
createdb: database creation failed

How do I retrieve all the databases from the directory? I hope I am not
doomed...

Thank you very much.

Afra


> Restoring the *entire* data directory should work.
>
> It seems to me that there's a great deal you haven't told us; if you
> want useful help it's better to err on the side of too much info,
> not too little.  For starters, what happens when you try to pg_dump?
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)


pgsql-general by date:

Previous
From: Tino Wildenhain
Date:
Subject: Re: [HACKERS] Anyone want to assist with the
Next
From: Tom Lane
Date:
Subject: Re: Restoring databases using only data/ dir