Is it possible to restore a Postgres database when only having access to the table files under $PGDATA/base/<db_oid>
? The system catalogs are empty.
Background
Somebody with sudo
executed an rm -Rf
under /var/lib
. Random files where deleted, but not the ones of the database I am interested in. Postgres would not start, even after I restored several files/directories by hand. So I created a new $PGDATA
and copied the database files in, hoping that Postgres would automatically read them. Apparently, Postgres relies a lot on its system catalogs to maintain links between what is on disk and what the user sees.
-
Without the commit log and the global tablespace, it will take an expert to extract anything.Laurenz Albe– Laurenz Albe2020年04月09日 06:59:42 +00:00Commented Apr 9, 2020 at 6:59
1 Answer 1
This doesn't sound promising. Do you know how you got into this predicament?
What specific system tables are empty? A good chunk of the system catalogs are located inside $PGDATA/base/<db_oid>
Do you have any recent backups that could be used to splice together whatever it is that you are missing?
Of course the first step it to make a backup of the current state of things, so if you somehow make things even worse you can go back and try again.
-
Thanks! I 've updated the question with some background info.Georgios Gousios– Georgios Gousios2020年04月08日 21:40:14 +00:00Commented Apr 8, 2020 at 21:40