I was tasked with recovering data from an old, unmaintaned server, where its main purpose application was no longer working. Basically just want to get a postgres db dump before burning the server to the ground.
I ssh into the instance, but cannot access the database.
psql: FATAL: database "foobar" does not exist
That's weird. I do pg_lscluster
Version Cluster Port Status Owner Data directory Log file
9.1 main 5433 online postgres /var/lib/postgresql/9.1/main /var/log/postgresql/postgresql-9.1-main.log
Okay, something is running. I check the data dir ls /var/lib/postgresql/
8.4 9.1
Huh, okay then. looking at the contents of the two dirs, it is pretty clear that all of the data is in the 8.4 folder, and the 9.1, I can see only holds default data, when I look using psql
for the running cluster.
So somehow the cluster that ran 8.4 was removed. No idea why or how (I'm not the only one with access to the server, but I cannot find anything supicious in bash history).
So how would I go about restoring access to the data, so I can pull out a dump?
pg_ctlcluster
,pg_lsclusters
and friends aren’t part of the Postgres project; they’re extensions installed by the Debian/Ubuntu packaging infrastructure. I’m not exactly sure whypg_lsclusters
doesn’t show your existing 8.4 installation. It might be that you have more than one cluster namedmain
. The first thing to do might be to check whether its configuration files still exist in/etc/postgresql/8.4/<clustername>
.$ ls /etc/postgresql/8.4/main/ environment pg_ctl.conf pg_hba.conf pg_ident.conf postgresql.conf start.conf