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
Best Answer
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:
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.