Skip to content

Instantly share code, notes, and snippets.

@oz
Created December 19, 2014 15:21
Show Gist options
  • Save oz/58c961df4b98563a8731 to your computer and use it in GitHub Desktop.
Save oz/58c961df4b98563a8731 to your computer and use it in GitHub Desktop.
Upgading from PG 9.3 to PG 9.4 on Mac OS X, with Homebrew

Brew upgrade...

Run the usual brew update, and brew upgrade to get the latest 9.4 version of PostgreSQL.

After upgrading PG from 9.3 to 9.4 with brew, the server will not start as is. If you value your database contents, and configuration, pg_upgrade is here to migrate those.

Do not delete the old binaries at once: do not run brew cleanup, because you need 9.3 binaries to migrate.

Migration

By default, your PG should be in /usr/local/var/postgres, but those files are not compatible with the latest 9.4 release.

With that, the upgrade is simple enough:

$ mv /usr/local/var/postgres /usr/local/var/postgres93
$ initdb -D /usr/local/var/postgres
$ pg_upgrade -b /usr/local/Cellar/postgresql/9.3.5_1/bin -B /usr/local/Cellar/postgresql/9.4.0/bin -d /usr/local/var/postgres93 -D /usr/local/var/postgres

If all goes well, you can start postgres -D ..., and cleanup the old stuff:

$ rm -fr /usr/local/var/postgres93
$ brew cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment