recover postgresql database after removal with --purge
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.