Last active
November 26, 2020 23:03
-
-
Save wosephjeber/d932d1d2a7016dbced9d82af87f629ba to your computer and use it in GitHub Desktop.
Upgrade from postgres 9.6.2 to 10.5 on OSX
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
## Following these commands should upgrade and migrate your existing database. | |
## This is an example of going from 9.6.2 to 10.5 on OSX. | |
## Be sure to update any version numbers based on the versions you're upgrading from and to. | |
## Adapted from https://stackoverflow.com/questions/24379373/how-to-upgrade-postgresql-from-version-9-6-to-version-10-1-without-losing-data | |
## Backup your database, just in case (replace databasename with your actual DB name) | |
pg_dump databasename > ~/Desktop/dev_dump | |
## Stop postgres | |
brew services stop postgresql | |
## Upgrade with Homebrew | |
brew update | |
brew upgrade postgresql | |
## Initialize a new 10.5 database | |
initdb /usr/local/var/postgres10.5 -E utf8 | |
## run pg_upgrade (change | |
pg_upgrade -v -d /usr/local/var/postgres -D /usr/local/var/postgres10.5 -b /usr/local/Cellar/postgresql/9.6.2/bin/ -B /usr/local/Cellar/postgresql/10.5/bin/ | |
## move data into new place | |
cd /usr/local/var | |
mv postgres postgres9.6.2 | |
mv postgres10.5 postgres | |
## restart postgres | |
brew services start postgresql |
Can't you just run:
brew postgresql-upgrade-database
after line 15?
Can't you just run:
brew postgresql-upgrade-database
after line 15?
Works
Yeah, it’s much easier to upgrade Postgres now than it was when I wrote this gist!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this!