Skip to content

Instantly share code, notes, and snippets.

@AndreiRailean
Forked from cjolly/pg.sh
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreiRailean/dea9a96c8f5297356b7a to your computer and use it in GitHub Desktop.
Save AndreiRailean/dea9a96c8f5297356b7a to your computer and use it in GitHub Desktop.
mac upgrade postgres to 9.4.0 after automatic homebrew upgrade
newpg=9.4.0
oldpg=9.3.5_1 # set this to your current PG version
# Stop current Postgres server
# launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
# Backup current db
mv /usr/local/var/postgres/ /usr/local/var/postgres-$oldpg
# Homebrew
# Check here if you have issues with either of these https://github.com/Homebrew/homebrew/wiki#troubleshooting
# brew update
# brew upgrade postgresql
# OS X launch agents for PG, so it starts on boot automatically
# cp /usr/local/Cellar/postgresql/$newpg/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
# These settings may or may not be necessary, investigate on your own
# http://www.postgresql.org/docs/9.3/static/kernel-resources.html
# sudo sysctl -w kern.sysv.shmall=65536
# sudo sysctl -w kern.sysv.shmmax=16777216
# Create new DB
initdb /usr/local/var/postgres
# Upgrade old DB to new DB
mkdir -p /tmp/pgupgrade && cd $_
pg_upgrade -d /usr/local/var/postgres-$oldpg/ \
-D /usr/local/var/postgres \
-b /usr/local/Cellar/postgresql/$oldpg/bin \
-B /usr/local/Cellar/postgresql/$newpg/bin
# Start new Postgres server
# launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
echo "Check if it works and delete /usr/local/var/postgres-$oldpg"
@AndreiRailean
Copy link
Author

this is a simplified fork of a script by cjolly: https://gist.github.com/cjolly/2870054
my postgresql was already upgraded. i just needed to be able to use it, so I commented out all the unnecessary steps

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