Skip to content

Instantly share code, notes, and snippets.

@llimllib
Created February 24, 2011 21:43
Show Gist options
  • Save llimllib/842950 to your computer and use it in GitHub Desktop.
Save llimllib/842950 to your computer and use it in GitHub Desktop.
#have homebrew install postgres 9... I did this accidentally so this command may or may not work
brew install postgres
#dump all DBs
/usr/local/Cellar/postgresql/8.4.4/bin/pg_dumpall -p 5432 > postgres8.4.backup.sql
#stop postgres 8.4
launchctl unload -w Library/LaunchAgents/org.postgresql.postgres.plist
#backup its data to a new dir
mv /usr/local/var/postgres /usr/local/var/postgres8.4
#init a 9.0 DB at /usr/local/var/postgres
initdb /usr/local/var/postgres
#copy the new plist into LaunchAgents
cp /usr/local/Cellar/postgresql/9.0.3/org.postgresql.postgres.plist ~/Library/LaunchAgents
#start postgres 9
launchctl load -w Library/LaunchAgents/org.postgresql.postgres.plist
#and load all our data into it
psql -f postgres8.4.backup.sql postgres
#now rebuild pg (I'm not sure this is necessary, but I did it, it works, and I needed to upgrade anyway)
gem uninstall pg
gem install pg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment