PostgreSQL 8.3 package reinstall/remove

Asked by Paulius Sladkevičius @ hbee

I'm using Ubuntu 8.10 32bit. I did mistake, I remove /var/lib/postgresql/8.3/ catalog and now I get error when I want to reinstall or remove PostgreSQL 8.3 package. Thank you.

sudo aptitude -f remove postgresql-8.3
[sudo] password for komsas:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initialising package states... Done
The following packages will be REMOVED:
  postgresql-8.3
0 packages upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Need to get 0B of archives. After unpacking 14.1MB will be freed.
Writing extended state information... Done
(Reading database ... 151660 files and directories currently installed.)
Removing postgresql-8.3 ...
 * Stopping PostgreSQL 8.3 database server * Error: /var/lib/postgresql/8.3/main is not accessible or does not exist
                                                                         [fail]
invoke-rc.d: initscript postgresql-8.3, action "stop" failed.
dpkg: error processing postgresql-8.3 (--remove):
 subprocess pre-removal script returned error exit status 1
Errors were encountered while processing:
 postgresql-8.3
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install. Trying to recover:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initialising package states... Done

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu postgresql-8.3 Edit question
Assignee:
No assignee Edit question
Solved by:
Mark Rijckenberg
Solved:
Last query:
Last reply:
Revision history for this message
Best Mark Rijckenberg (markrijckenberg) said :
#1

Hi,

Recreate the directory /var/lib/postgresql/8.3/main using the following commands:

sudo mkdir /var/lib/postgresql
sudo mkdir /var/lib/postgresql/8.3
sudo mkdir /var/lib/postgresql/8.3/main

Then retry removing the package. If it still fails, then you need to first recreate the other directories that aptitude complains about.

Regards,

Mark

Revision history for this message
Paulius Sladkevičius @ hbee (komsas) said :
#2

Hi,

Thanks Mark, all package related with postgresql I reinstall. But now I have problem that after reinstall /var/lib/postgresql/8.3/main is empty, how to get back it?

Revision history for this message
Paulius Sladkevičius @ hbee (komsas) said :
#3

I did two things to get back my postgresql:
 - pg_createcluster 8.3 main --start (to restore /var/lib/postgresql/8.3/main dir and others)
 - sudo apt-get --purge remove postgresql-8.3 (and install, get back my init.d script)

I not sure that pg_createcluster command was necessary.

Revision history for this message
Paulius Sladkevičius @ hbee (komsas) said :
#4

Thanks Mark Rijckenberg, that solved my question.