Why does a system upgrade take so long if there are files in '/usr/local'?
The problem is only accute if you have a lot of files in /usr/local -- a few hundred files is not a problem. It needs to be many thousands of files. The reason, according to this post, is:


  Part of the upgrade involves moving /usr/local out of the way. The process of moving those files back after the upgrade is done one file at a time and seems very slow.


He goes on to recommend removing anything from your Homebrew installs that isn't currently necessary with the brew remove; brew cleanup command pair. You can also move it aside, temporarily, naming it something like /usr/local.mine and then move it back after the update -- though this can make working with your Mac slightly problematic if you've, for example, switched your default shell for your account to be the Homebrew-supplied zsh or something like that.

Personally I opted to clean up my Homebrew installs. I also removed any Homebrew-installed daemons (MySQL, PostgreSQL and Redis) completely and shut them down. They're easy enough to get back after the installation is complete. In the end I had only a handful of Homebrew packages installed still that were very essential to me and the installation time wasn't too bad -- about 2 hours on an old iMac.

Of course, you can also wipe everything and just start again. First save everything you have installed:

brew list | sed s/\s+/\\n/g | tee my-brew-packages.txt


And now remove them all with:

cat ~/my-brew-packages.txt | xargs brew remove --force
brew cleanup --force


And to re-install things after you've updated:

cat ~/my-brew-packages.txt | xargs brew install