Last active
October 18, 2017 05:52
-
-
Save JLHwung/4133804cf67dd87a36473396a3926563 to your computer and use it in GitHub Desktop.
homebrew-postgresql-upgrade-10
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
# install postgresql 10 | |
brew upgrade postgresql | |
# Check version by `brew list --versions postgres` | |
export OLD_POSTGRES_VERSION=9.6.5; | |
export NEW_POSTGRES_VERSION=10.0; | |
# Stop postgresql service | |
brew services stop postgresql | |
initdb /usr/local/var/postgres$NEW_POSTGRES_VERSION -E utf8 | |
pg_upgrade -v \ | |
--old-datadir /usr/local/var/postgres \ | |
--new-datadir /usr/local/var/postgres$NEW_POSTGRES_VERSION \ | |
--old-bindir /usr/local/Cellar/postgresql/$OLD_POSTGRES_VERSION/bin \ | |
--new-bindir /usr/local/Cellar/postgresql/$NEW_POSTGRES_VERSION/bin | |
# Rebase data | |
mv /usr/local/var/postgres /usr/local/var/postgres$OLD_POSTGRES_VERSION | |
mv /usr/local/var/postgres$NEW_POSTGRES_VERSION /usr/local/var/postgres | |
# Start service | |
brew services start postgresql | |
# Optimize new cluster | |
./analyze_new_cluster.sh | |
# Uncomment to cleanup old postgresql, not recommended before you have sufficient confidence on the DB upgrade | |
# brew cleanup | |
# rm -rf /usr/local/var/postgres$OLD_POSTGRES_VERSION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment