-
-
Save andikan/9994908 to your computer and use it in GitHub Desktop.
This file contains 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.3.2 | |
oldpg=9.2.4 # 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 | |
# Clean new DB | |
./analyze_new_cluster.sh | |
# After determining upgrade successful you can remove old DB. | |
./delete_old_cluster.sh | |
# Go home | |
cd ~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment