Skip to content

Instantly share code, notes, and snippets.

@rafaelss
Created September 11, 2012 19:04
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save rafaelss/3700977 to your computer and use it in GitHub Desktop.
Save rafaelss/3700977 to your computer and use it in GitHub Desktop.
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. pg_ctl -D /usr/local/var/postgres stop -s -m fast
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. curl https://raw.github.com/fragility/homebrew/737af01178590950749cf5e841f2d086c57c5a80/Library/Formula/postgresql.rb > /usr/local/Library/Formula/postgresql.rb
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@swingman
Copy link

Using launchctl to run PostgreSQL, so I suspect the postgres server will relaunch within a few seconds of executing line 1.
Line 1 becomes:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Replace 7 with:
cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

@swingman
Copy link

When running my version, pg_upgrade refused to run claiming postmaster was still running, so I had to delete a stale postmaster.pid file inside the 9.1.5 directory.

@afair
Copy link

afair commented Sep 13, 2012

Remember it is always good to do a pg_dumpall before you start!

Also, I had a problem with pg_upgrade, it did not like that I had different lc_collate on each database setup, and did not run. I suspect that was due to the "-E utf8" option to initdb, which I may not have had before (but want now).

So I restored from the dump I took. :-)

@phil-monroe
Copy link

For postgres 9.2.1:

2. curl https://raw.github.com/fragility/homebrew/master/Library/Formula/postgresql.rb  > /usr/local/Library/Formula/postgresql.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment