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?

2 Answers 2


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...

  • That much is obvious. However, 8.2.7 cannot be re-emerged. That is the problem.
    – user57129
    Oct 14, 2010 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. Oct 14, 2010 at 15:08
  • You can download the 8.2.7 ebuild and associated files from sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-db/… Oct 14, 2010 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy