Thread: HELP! Uninstalled wrong version of postgres

HELP! Uninstalled wrong version of postgres

From
Howard News
Date:
Hi,

I uninstalled the wrong version of postgres on Ubuntu using apt-get
remove postgresql-9.0, convinced that this was an old unused version.
You guess the rest...

The data files still appear to be there, all 485GB of them. Can these be
restored?

Thanks.


Re: HELP! Uninstalled wrong version of postgres

From
Leonardo M. Ramé
Date:
El 24/03/16 a las 14:19, Howard News escribió:
> Hi,
>
> I uninstalled the wrong version of postgres on Ubuntu using apt-get
> remove postgresql-9.0, convinced that this was an old unused version.
> You guess the rest...
>
> The data files still appear to be there, all 485GB of them. Can these be
> restored?
>
> Thanks.
>

Ok, if the data files are still there I'd do this:

1) Assuming the data is in /var/lib/postgresql/9.0, rename that
directory to /var/lib/9.0-old, AND COPY THAT DIRECTORY ELSEWHERE.
2) Reinstall 9.0 with "apt-get install postgresql-9.0". This should
re-create the /var/lib/9.0 directory with an empty "main" dir.
3) Stop 9.0 with "pg_ctlcluster 9.0 main stop".
4) Rename the new directory /var/lib/9.0 to /var/lib/9.0-new
5) Rename the old dir (/var/lib/9.0-old) to /var/lib/9.0
6) Restart the cluster with "pg_ctlcluster 9.0 main start".

And everything should be fine again.

P.S.: All those steps should be done as root.

Regards,
--
Leonardo M. Ramé
http://leonardorame.blogspot.com