recover postgresql database after removal with --purge 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?
Check /var/lib/postgresql/&lt;version&gt;. 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.