Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to restore postgresql DB without backup

Forgot to make a backup. Now I have harddrive with databases and new system with empty postgres. Can I somehow restore databases? by simple copy of files etc?

like image 274
Timur Sadykov Avatar asked Dec 22 '22 03:12

Timur Sadykov


1 Answers

If you have the full data directory of your old postgresql system (and if it was the same version, or differing only in a revision number) you can just try to put it in place of your data directory in your new postgresql installation. (Of course, stop postgres server before doing this).

It's basically the same procedure used when upgrading postgresql, when there is no need to do backup-restore.

Edit: As pointed out in the comments, I assume not only same (or almost same) version, but same architecture (32 - 64 bits , Linux - Windows, etc)

like image 57
leonbloy Avatar answered Jan 04 '23 01:01

leonbloy