1

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.

1
  • Without the commit log and the global tablespace, it will take an expert to extract anything. Apr 9, 2020 at 6:59

1 Answer 1

0

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.

1
  • Thanks! I 've updated the question with some background info. Apr 8, 2020 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.