Page 1 of 1

Restoring postgresql database

PostPosted: Tue Mar 21, 2023 6:59 am
by Mads
Hi,

I recently lost my harddrive where my postgressql database was stored. Data from a given sql installation is normally stored in somepath/sql-folder/data. However I dont have a complete backup of the data folder but rather I have a copy of one of the 'data/base/somenumber' subfolders. Can this subfolder be used to restore the database? I have tried to reinstall postgress sql and move this aforementioned subfolder into the new "base" folder. However postgressql does not recognize this folder it seems. (it just doesnt show up when starting the pg-admin. No error msg). I have searched stackoverflow etc. But I cant seem to find any relevant posts related to my scenario.

Anyone have any thoughts on if its possible to get postgressql to recognize this folder? Or is this subfolder alone not enough to restore the database?

Thanks for taking the time to read!

Kind Regards,

A desperate Mads

Re: Restoring postgresql database

PostPosted: Tue Mar 21, 2023 12:06 pm
by Flag_Hippo
You need the original data folder which is here by default:

C:/Program Files/PostgreSQL/x/data

where 'x' is the PostgreSQL version. When reinstalling PostgreSQL you have to use the same major version of PostgreSQL that was used before and during the install it should detect the existing 'data' folder and use that.

Re: Restoring postgresql database

PostPosted: Tue Mar 21, 2023 12:54 pm
by Mads
I was afraid that was the case.Thank you for taking the time to answer. Much appreciated.

Kind regards,

Mads