Created
July 7, 2014 20:56
-
-
Save nonword/ae0cb1a91c75ca039e22 to your computer and use it in GitHub Desktop.
Upgrade Postgres data dir from 9.2 to 9.32 after updating bins via brew
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
# Adapted from https://gist.github.com/joho/3735740 | |
# After upgrading OSX to Mavericks, pg was all confused. So I: | |
brew update && brew upgrade | |
# But this only updated pg libs (from 9.2 to 9.32) without updating data dir, so I: | |
# Stop service: | |
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
# Move old data dir to temp location | |
sudo mv /usr/local/var/postgres /usr/local/var/postgres92 | |
# Initialize new empty 9.32 data dir | |
mkdir /usr/local/var/postgres | |
sudo chown _postgres /usr/local/var/postgres | |
sudo -u _postgres initdb /usr/local/var/postgres -E utf8 | |
# Create temporary working space ownable by _postgres user | |
mkdir ~/pg_upgrade | |
sudo chown _postgres ~/pg_upgrade | |
cd ~/pg_upgrade | |
# Upgrade the old data dir into the new dir: | |
sudo -u _postgres pg_upgrade -b /usr/local/Cellar/postgresql/9.2.1/bin -B /usr/local/Cellar/postgresql/9.3.4/bin -d /usr/local/var/postgres92 -D /usr/local/var/postgres | |
# Ensure startup script is current: | |
cp /usr/local/Cellar/postgresql/9.3.4/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/ | |
# Start server: | |
sudo -u _postgres pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment