Check
brew info postgresql
psql --version
Backup
mv /usr/local/var/postgres/ /usr/local/var/postgres.x.x.backup/
Init new DB
initdb /usr/local/var/postgres/
/usr/local/opt/postgresql/bin/initdb --locale=de_DE.UTF-8 -D /usr/local/var/postgres -E utf8
Stop
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
pg_ctl -D /usr/local/var/postgres stop -m fast
pg_ctl -D /usr/local/var/postgres.x.x.backup stop -m fast
Upgrade
pg_upgrade -b /usr/local/Cellar/postgresql/x.old/bin/ -B /usr/local/Cellar/postgresql/x.new/bin/ -d /usr/local/var/postgres.x.x.backup/ -D /usr/local/var/postgres
Restart
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist