Search code examples
postgresqlmigrategentoo

Migrate Postgres DB when the source Postgres server is offline


So yea the title says it all, I need to somehow get the DBs form the source server to the new server, but the kicker is the old server is falling apart :P and is there a way I can just move it all to the new server and import it?

the old server just refuses to run Postgres anymore and i am almost certain that the version that was running on the old server is 8.4, and the new server is running 9.2, will that cause an issue?

this is what I get when i try to start Postgres on the old server,

/etc/init.d/postgresql-8.4 start
* Use of the opts variable is deprecated and will be
* removed in the future.
* Please use extra_commands, extra_started_commands or extra_stopped_commands.
* Starting PostgreSQL ...
could not start server   [ !! ]
* ERROR: postgresql-8.4 failed to start

also I am running gentoo :)

thanks in advance for your help!


Solution

  • You can copy the data files directly, but you must use the same major version of PG on the destination server (e.g. 8.4.x - the "8.4" is the major). Easiest way to check the version is via psql -V.

    The upgrade procedure in this situation isn't too hard if you want to move up to a 9.x release. You'll need to install 8.4 on the new server (either via a package or by hand), then you'll want to use the pg_upgrade tool to do the upgrade. pg_upgrade comes with recent releases of PG, so expect to have two installations on the server during that time.

    You can find the docs here.