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?
1 Answer 1
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.
-
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!eftshift0– eftshift02018年08月18日 08:53:23 +00:00Commented Aug 18, 2018 at 8:53
-
@eftshift0 I am sure that this "magisrescue" can't find deleted postgresql database table files.peterh– peterh2018年08月18日 17:39:04 +00:00Commented Aug 18, 2018 at 17:39