views:

111

answers:

1

Hello all,

I have the following problem and I need to know if there´s a way to fix it.

I have a client who was cheap enough to decline buying a backup plan for his postgreSQL databases on the main system that runs his company and as I thought it would happen some day, some OS files crashed during a blackout and the OS needs to be reinstalled.

This client didn't have any backups of the databases but I managed to save the PostgreSQL main directory. I read that the databases are stored somehow inside the data directory of the postgres main folder.

My question is: Is there any way to recover the databases from the data folder only? I am working in a windows environment (XP service pack 2) with PostgreSQL 8.2 and I need to reinstall PostgreSQL in a new server. I would need to recreate the databases in the new environment and somehow attach the old files to the new database instances. I know that's possible in SQL Server because of the way that engine stores the databases but I have no clue in postgres.

Any ideas? They would be much appreciated.

+1  A: 

If you have the whole data folder, you have everything you need (as long as architecture is the same). Just try restoring it on another machine before wiping this one out, in case you didn't copy something.

Just save the data directory to disk. When launching Postgres, set the parameter telling it where the data directory is (see: wiki.postgresql.org). Or remove original data directory of the fresh installation and place the copy in its place.

Konrad Garus
wow, that seems very easy, let me give it a try tomorrow and I'll let you know the result. Thanks for the quick answer ;)
Alvos
I tried that and it should work but for I think the data folder was corrupted because it didn't work. It should when the data folder is ok though. I had transaction files as a backup and it will take me longer to recover the historical data but I think I will be able to recover everything. It will just take more time than I hoped. Thank you for your help. I tried your solution in a test environment and it does work.
Alvos