4

When recovering the Postgresql database from a hacked Ubuntu 12.04 server, I copied the data directory to another location, reinstalled the OS and PostgreSQL, stopped PostgreSQL service, removed the contents in the data directory and copied back the contents from the previous installation.

Problem: PostgreSQL will not start now, showing the errors below. Why is this happening, and how can we fix the problem?

service postgresql restart
* Restarting PostgreSQL 9.1 database server                                     

* Error: could not exec /usr/lib/postgresql/9.1/bin/pg_ctl /usr/lib/postgresql/9.1/bin/pg_ctl start -D /var/lib/postgresql/9.1/main -l /var/log/postgresql/postgresql-9.1-main.log -s -o -c config_file="/etc/postgresql/9.1/main/postgresql.conf" :


Update

Restarting PostgreSQL service now gives the error:

* Restarting PostgreSQL 9.1 database server                                     
* The PostgreSQL server failed to start. Please check the log output:
2013-04-16 01:52:10 EDT PANIC:  could not open control file "global/pg_control": Permission denied
  • 2
    "Permission denied". Have you checked the obvious? – Colin 't Hart Apr 16 '13 at 7:22
  • 1
    Setting the permissions solved it :) – Nyxynyx Apr 16 '13 at 7:24
0

There are some preconditions which should be met in order to get this working. I see your case basically the same as a physical backup and restore, which is covered well in the documentation. The main points are:

  • you have to take a consistent snapshot (PostgreSQL should be stoped first)
  • you have to copy the whole cluster (looks like this is done by your part)
  • you have to copy the commit log files in pg_clog/

And for me it looks like that your error message has at least one following line, which probably tells what the problem is.

7

I ran into the same problem. To clarify what Nyxynyx hints towards in his comment, the resolution was to give permissions to access the db cluster dir (the path that follows -D in the error):

chown -R postgres:postgres /var/lib/postgresql/9.1/main
0

Just for the case that anyone has the problem on Windows Server:

Giving the group "Network Service" full access to the data folder solves it.

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.