Macports is one of the most popular package manager system for MacOS. Usually, when you want to install Macports, you will download the automatic installer from Macports website. This is convenient for those people who first come to Macports’s world. Usually, the best way to backup with Mac is to backup your home directory. However, Macports by default will install all its packages into /opt/local, which make it difficult when you want to re-install your whole system or migrate to a new Mac because it’s outside your home directory.
The solution is to install Macports into your home directory and config it to put all its stuff into your home directory, too. By using this method, you can easily backup your home directory and start your work immediately with all your favorite applications/packages when you re-install the whole system.
There is one thing to notice. Not all packages from Macports can be installed and launched from your home directory. The ones that cannot are those that need to create another user, interact with folders outside your home dir,… (tasks that need sudo permission). One example that I have encountered is Mysql server. It needs to create another user to run the instance of Mysql but I think we can config it (I have not tried yet). To fix this, simply install 2 instances of Macports, one using the default installer and one in your home directory.
Read more