1

I noticed, after a while, that when I got new versions of postgresql (I'm using debian testing) they were being installed while keeping older versions of the DBMS running in parallel (one listening on a different port and so on). So, without thinking much about it, I just ran dpkg remove --purge on the older versions without realizing that the DB that I was using was actually running on the oldest version installed. Is there DB data on the FS that is not deleted if removing the postgresql package with --purge so that I can get the DB back?

asked Aug 18, 2018 at 5:18

1 Answer 1

2

Check /var/lib/postgresql/<version>. There are the database files.

If this directory doesn't exist, it was removed. What exactly happens on --purge removal, it depends on the distro (more exactly, on the deinstall scripts were called with a different parameter in /var/lib/dpkg/info). It depends on the scripts (which were provided by the package), what will exactly happen. The logic of the --purge dictates a real, full removal.

If it happened, the data - at least partially - is probably still available on your disk, so a recovery is still not impossible (except the overwritten sectors), but it is very unlikely that you can do that.

To do that, you would need to power off your system (yes, it is one of the rare cases where explicitly power off without any sync, etc is needed), then reboot from without mounting it, and then doing a block-level scan for postgresql database files by its signatures.

Always have a periodic, automatical backup from your databases.

answered Aug 18, 2018 at 7:28
2
  • Thanks for the detailed response. It's a development box so going after db files with magicrescue won't be necessary. :-) Seems like the DB is gone.... anyway, will set up the development data again. Thanks again! Commented Aug 18, 2018 at 8:53
  • @eftshift0 I am sure that this "magisrescue" can't find deleted postgresql database table files. Commented Aug 18, 2018 at 17:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.