-
-
Save AndreiRailean/dea9a96c8f5297356b7a to your computer and use it in GitHub Desktop.
mac upgrade postgres to 9.4.0 after automatic homebrew upgrade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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