Reputation: 1275
I have a Postgresql 10 installation on Ubuntu 18.04 that somehow broke and won't restart. Can I just reinstall it without destroying its databases, so that I can access the databases again? pg_dump
doesn't work.
Upvotes: 1
Views: 3219
Reputation: 191
Yes, you can do that.
By default, your databases and other important files are stored in PGDATA.
Traditionally, the configuration and data files used by a database cluster are stored together within the cluster's data directory, commonly referred to as PGDATA (after the name of the environment variable that can be used to define it). A common location for PGDATA is /var/lib/pgsql/data.
https://www.postgresql.org/docs/10/storage-file-layout.html
I don't know how you will uninstall PostgreSQL, but be sure to keep PGDATA.
(yum or apt won't delete PGDATA)
After re-installing PostgreSQL, make sure to launch your PostgreSQL with your existing PGDATA
pg_ctl start -D YOUR_EXISTING_PGDATA/
Upvotes: 2