2

I ran sudo -u postgres psql -c "show data_directory" and it shows /var/lib/postgresql/9.5/main. If I understand correctly, this is the directory that stores the database files.

I ran sudo apt-get purge postgr*. Did this remove the database files? Running sudo apt-file list postgresql did not show /var/lib/postgresql in its entries, which means it shouldn't have purged those files, right?

The reason I'm asking is that I'm not exactly sure what data there was in the database and running ls -l /var/lib/postgresql is showing "time modified" around the time that I purged postgresql on all files.

2

The Debian packages of PostgreSQL before version 11 delete clusters when the server package is removed; so purging postgresql-9.5 in your case would have deleted the database. (See the posgresql-9.6 postrm for the gory details.)

You’re not the first person to be surprised by this; bug #911940 requested that the data be left alone, and PostgreSQL 11 in Debian 10 will ask the user before deleting the databases.

(apt-file list or dpkg -L aren’t reliable indicators of what will be purged; purging can involve maintainer scripts which can delete other files.)

  • well, this sucks – n3onis May 14 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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