I have an old version of postgres (8.4.13) that doesn't run for various reasons. I plan to move the database files in there to a new install of postgres 9.3. How would I go about doing this? For one I can not start up postgres when I run:

postgres -D /var/lib/pgsql/9.2/data

As I get :

FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 8.4.13.

The easiest route would be to figuring out how to run this server but if not how would I locate the db files in it?


How this actually happened was last week I wanted to intiliaze postgres server commands so I could easily stop and restart the server since my knowledge of postgresql is pretty limited. I ended up installing postgresql-server for RHEL and it was initially working fine. The commands weren't working so I forgot about it. The databases were working fine too at that time. I log on today and to my shock the commands were working but it also wiped the dbs. So my presumption is it installed a completely new server that could be accessed via the commands.

Somehow this tampered whatever settings I had.

Typing postgresql --version gives me version 8.4.13. If I can only start it now by pointing postgres -D to the correct pgsql.

There are two pgsql dirs:


The latter seems to be the newest install of postgresql as the pg_hba.conf files are unedited.

I used to be able to start the 8.4.13 server with 9.2 it would just give me a WARNING: Some features might not be available. I don't know why installing postgresql-server would change this now. As they are separate dirs.

  • I deleted it... – user2769651 Jun 16 '14 at 17:27
  • You say you have 8.4 and want to run 9.2, but the error says you have a 9.2 datadir and are trying to load it with 8.4. Which is it? You need to explain this properly. "for various reasons" - what reasons? How did you get to this point? What exactly is the problem? What are you trying to achieve? Please edit the question to expand and clarify it. Remember, we don't know what you've done or anything about your setup unless you say. Comment here when you've edited please. – Craig Ringer Jun 16 '14 at 17:31
  • Ah, this looks like some of the missing context, but it's pretty confused as well. dba.stackexchange.com/q/68330/7788 – Craig Ringer Jun 16 '14 at 17:33
  • I guess I need to install 9.2 and point it to the 9.2 datadir to get it to work. Thanks. – user2769651 Jun 16 '14 at 18:42
  • See my answer to dba.stackexchange.com/q/68330/7788 – harmic Jun 17 '14 at 1:18

Only the same major version can read the data files.

You need to upgrade properly. To do that you'll have to install 8.4, then use pg_upgrade, or use pg_dump and pg_restore. See the manual for more information.

That said, the error actually has the versions the other way around - it says you're running 8.4 binaries and trying to point them at a datadir from 9.2. Verify this with postgres --version. If you turn out to have 8.4 binaries and a 9.2 datadir then pg_upgrade won't do you any good - you just need to install 9.2 (or use the correct PATH if it's already installed) and run the 9.2 datadir using 9.2 binaries.

Update given extra info in question:

It is very likely that both 8.4 and 9.2 are running fine on your machine, just on different ports.

sudo netstat -ltnp |grep postgres

will show you listening PostgreSQL servers, and

psql -p 5433

(or whatever) will connect to a different port.

The databases appeared to vanish because when you installed the new PostgreSQL it became the default version that's run.

If you find that the 8.4 install is in fact not running, you probably just need to change the port it starts on in its configuration so it runs on a different port, then connect to it as shown above.

| improve this answer | |
  • by doing this will I be tampering with existing postgres installations? – user2769651 Jun 16 '14 at 17:27
  • You can have multiple versions of PostgreSQL installed side-by-side. I can't really supply details given that you didn't mention your OS/version etc. Especially as your description doesn't match the error message you showed either. – Craig Ringer Jun 16 '14 at 17:30
  • the postgreSQl version is 8.4.13. If the 8.4 binaries exist shouldn't 8.4 be installed then? OS is Centos 6 btw. – user2769651 Jun 16 '14 at 17:34
  • Yes. Your description of the problem was wrong and didn't match the actual problem shown by the error. Your problem seems to be that you're trying to start a 9.2 database using binaries from 8.4. You need the 9.2 binaries. These might be installed and just not the default ones on the path. It's impossible to know from the amount of information you have provided. You need to show a detailed history of how you got into this mess - what you did to get here. – Craig Ringer Jun 16 '14 at 17:35
  • Answer updated. – Craig Ringer Jun 17 '14 at 2:04

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.