Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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
share|improve this question
    
"Permission denied". Have you checked the obvious? –  Colin 't Hart Apr 16 '13 at 7:22
    
Setting the permissions solved it :) –  Nyxynyx Apr 16 '13 at 7:24

2 Answers 2

up vote 0 down vote accepted

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.

share|improve this answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.