"Reinstalling" /usr and /local folder
When you upgrade OS X the installer preserves the things that you've installed to /usr/local (through Homebrew) and /opt (through MacPorts). Always a good idea to have backups though, just in case.

It has been suggested that you might want to temporarily move the contents of /usr/local to speed up the install though. Faster Mac OS X 10.10 Yosemite Upgrades for Developers