Updating Postgres to 13.1 with Homebrew
With the update to macOS 11 Big Sur, and the updates I keep doing to my linode box, I thought it would be a nice time to update Postgres to the latest that Homebrew had - I was expecting 12.5, as that's what's latest for Ubuntu 20.04LTS at linode, and it was surprisingly easy - even with the major version update.
The standard upgrade for anything in Homebrew is:
$ brew upgrade postgres
and it will upgrade the binaries as well as upgrade the database files - if it's a minor release change. But if it's a major release change - like it was for me from 12.x to 13.x, then you also have to run:
$ brew postgresql-upgrade-database
and that will update the database files and place the old database files in /usr/local/var/postgres.old so after you're sure everything is running OK, you just need to:
$ rm -rf /usr/local/var/postgres.old
and it's all cleaned up.
The one wrinkle is that I have set up the environment variable not to do automatic cleanups of the old versions of packages - because I wanted to have multiple versions of Leiningen hanging around, so I needed to clean up the old versions of postgres with:
$ brew cleanup postgres Removing: /usr/local/Cellar/postgresql/11.1_1... (3,548 files, 40.3MB) Removing: /usr/local/Cellar/postgresql/12.1... (3,217 files, 37.7MB)
and then the old versions are cleaned up as well.
I was expecting 12.5... but got all the way to 13.1 - nice. 🙂