Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running Gentoo. I upgraded from Postgresql 8.2.7 to 9.0.1. Somewhere in the upgrade process, the old Postgresql got unmerged unstead of getting slotted, so it's gone. The old version is also gone from portage so I can't just re-emerge it. I have the Postgresql data directory with my database, but it is useless because Postgresql 9.0.1 refuses to run it due to the version mismatch.

I've tried many solutions but have been unable to fix this.

How can I get the database in my old 8.2.7 data directory to work with Postgresql 9.0.1?

share|improve this question

The official way to migrate a PostgreSQL database to a new major release is to dump and reimport:

As a general rule, the internal data storage format is subject to change between major releases of PostgreSQL (where the number after the first dot changes). [...]When you update between compatible versions, you can simply replace the executables and reuse the data directory on disk. Otherwise you need to back up your data and restore it on the new server.

So you will need a running installation of 8.2.7. One option is to manually install 8.2.7 on your system (by either building it yourself, or downloading some binary package, e.g. from Debian, and unpacking and installing it manually). Another would be to just install a distro that comes with 8.2.7 (on spare hardware, on an alternate partition, or in a VM).

Then copy your files there, start the database and do a pg_dumpall. You may have to tweak the PostgreSQL install so it accepts your data files.

P.S. I hope I do not have to stress that you should first test whether the backup of your database files (which you certainly have) can be restored without problems, just in case...

share|improve this answer
That much is obvious. However, 8.2.7 cannot be re-emerged. That is the problem. – user57129 Oct 14 '10 at 14:49
Did you even read the answer? sleske suggested that you build it yourself, i.e. download the source from the postgres site and follow their instructions to compile and install it. – ThatGraemeGuy Oct 14 '10 at 15:08
You can download the 8.2.7 ebuild and associated files from… – Mark Wagner Oct 14 '10 at 17:47

instead of completely manually building from source, you could also create your own overlay, find the old ebuild from somewhere on the internets and re-emerge 8.2 from your overlay.

share|improve this answer

Your Answer


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