Clean install your Mac without hesitation

David the Numb 
8 min readFeb 26, 2017

--

I approximately clean install my Mac every 3 years. To clarify, clean install here means I’ll do these following steps manually:

  1. Consciously and selectively backup files to external disk or cloud storage
  2. Format the startup disk and install latest macOS with pre-installed USB
  3. Migrate backup files and set up the environment just like before

Hmm, Sounds troublesome and horrifying, right? You may ask what if I forgot to backup something important? A software license costs $19, a photo worth memorizing or a one-time password that never typed again.

Then why would I or should you do this periodically anyway?

The clean install is all about regaining control of your Mac

After years of use, hundreds of folders and thousands of files had been created, moved or even duplicated. Some of them are operated intentionally by you, but the majority of them are not. It could be upgraded system altered paths, a newer version of app changed its sync method or you just forgot and import the data twice. Sometimes it simply occupies space more than you need, but sometimes it could lead to some annoying situation with no clue i.e. prompting password every time you move files to certain folder or wrong date for Calendar app icon.

Despite all that, let’s say you have your Mac working just fine, years of use means years of software iteration with either better alternative or simply no longer existed. Take Mail client as an example, I used built-in Mail app at the beginning, switching to Airmail app due to its faster and unified multi-devices user experiences and the Mailbox app because of its zero inbox philosophy, and after it was R.I.P. I’m using Spark app until now. No, you just use the built-in Mail app and feel just fine? How about Microsoft Office 2014 for Mac back then and Office 365 for now, or how about Adobe Photoshop and Sketch app? Now you can see, the software keeps evolving, therefore, the much you know them the better use of them you could make.

In order to better use of them, we walk through this process to review which software suits us, recognize what file worth migrating and remind which setting makes us feel like home again. With this process, we learn and get familiar more with not only the machine itself but also your habits then eventually regain control of you Mac. Of course, it’s hard and risky due to there’s always dust and blind spot somewhere, and that’s how conscious works. Fortunately there’re some tools to make this process as easy as possible. Most importantly, the result is an accumulation of work, that means you’ll benefit from previous work and enhance progressively.

The clean install is not only the process of re-installation, it’s the way to know the machine or the software better that could make you better use of them.

Now, we shall begin. The process contains three parts: backup, re-installation, and migration.

Part I: Backup

Requirement: You need an external drive with available space larger than your used space for Time Machine and extra more space for your migrated data

First thing first, lets Time Machine run a full machine backup. With this insurance, you’re able to restore everything, I mean EVERYTHING. If you’ve done anything wrong? Don’t worry, just restore it.

Sometimes the reason people hesitate to do clean install is just because they don’t have a clue about what and how should they backup their data. But once you figured the softwares are the core of data, there are only three types of data needed to be backup:

  1. Software you currently used
  2. Software data indirectly created by you including settings, history, backup, …etc
  3. Static files directly created by you including documents, photos, projects…etc

So we get started with making a list of them using Homebrew. Homebrew is a command line tool that you could manage almost every app you use, manage here by means you can install, uninstall and also make a list of them. If you’re a developer like me, you should probably use it right now, but if not, don’t worry, you could simply copy/paste couple lines of command and it just works.

  • Open your built-in Terminal app and paste this line then press enter
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Install mas-cli that makes Homebrew support Mac App Store
brew install mas
  • Use brew bundle command to dump the full app list
brew bundle dump

This command will create a file called Brewfile in the current folder(the terminal default is your home folder). It looks like this:

...
# format
# brew 'app_name'
# cask 'app_name'
# mas 'app_name', id: xxxxxxxxx
brew 'mas'
cask 'java'
mas 'iMovie', id: 408981434
...

Every line begins with these three keywords brew, cask, mas indicates the installation source of your app: brew installs most of command line tools, cask is the alternative way to install your Mac apps and mas is the command line interface of Mac App Store then the app name surrounded by quotation marks comes after with one space. The example above illustrates the format rules, lines are exchangeable and line begins with # means comments.

Last, review this list and compare with apps in your Application folder. If there’s app not on this list, it means you might not install it via Mac App Store, perhaps from developer’s website or CD-ROM. Use the brew cask search {app_name} command to find if there’s alternative way to install it.

brew cask search java
==> Exact Match
java ✔
==> Partial Matches
eclipse-java java-jdk-javadoc netbeans-java-ee netbeans-java-se yourkit-java-profiler
==> Remote Matches
caskroom/versions/java-beta

Hence brew-cask is a community-driven tool, you have big chance to find the app here. If so, add cask 'app_name' to your Brewfile. Otherwise, you have to backup the software manually or find an alternative app to replace it.

Congratulations! We have the complete list of apps in Brewfile. Put this file in somewhere you could reach like Dropbox, we will use it later.

For more detail information about Homebrew, you can visit homebrew, homebrew-bundle, homebrew-cask, or mas-cli. You can also see my revised result of brew bundle dump.

We have made and reviewed the full list of software we used, there are perhaps some comments about what the software is and pretty sure why we need it. Here comes the second part, the software data. In this part, we open every app we need, go through all setting, document or backup it to make sure we could restore everything we need afterward. How to do it depends on the way you use it or how much you know this software. Here are some common apps and how I do it.

* You’ll see tilde ~ symbol in the following section that means your home folder

System Preferences

  • General > Use dark menu bar and Dock
  • General > Recent items: None Documents, Apps, and Servers
  • Desktop & Screen Saver > Screen Saver > Start after 2 Minutes
  • Desktop & Screen Saver > Screen Saver > Use Apple TV Aerial Screen Saver for Mac

Keychains

  • Turn on iCloud Keychains sync

Safari

  • Backup Bookmarks from ~/Library/Safari/Bookmarks.plist
  • Backup Safari history from ~/Library/Safari/History*

Photos

  • Backup the whole library: ~/Pictures/Photos Library.photoslibrary

iTunes

iBooks

Messages

1Password

  • Enable iCloud sync
  • Backup backup files from ~/Library/Containers/2BUA8C4S2C.com.agilebits.onepassword-osx-helper/Data/Library/Backups/

Fonts

Dotfiles(Developer Only)

  • Backup ~/.ssh
  • Backup ~/.gitconfig
  • Backup ~/.zshrc

Finally, the third part, static files. Comparing to previous steps, this is the easiest part. Just review the following folder and decide whether you want to backup it or not. Or, just backup every folder.

  • ~/Desktop
  • ~/Documents
  • ~/Downloads
  • ~/Music except for the iTunes folder we already backed it up
  • ~/Movies
  • Any other folder you create to contain your personal files

Ta-da! you’ve done the great work! 🎉

Last but not least, this is not the complete list of how you do it. It depends on everyone’s need. To me, I’d like my machine to inherit the history of safari and messages and every piece of work I’d done, basically everything in my life. But we are different after all, maybe you are the let go type of person and pieces don’t bother you at all, that’s totally fine.

Part II: Re-installation

Requirement: An USB with available space larger than 8 GB

First, we need a bootable USB:

  • Download macOS Catalina
  • Open Disk Utility, click on the USB drive, click Erase format the USB with name Untitled and Mac OS Extended (Journaled)
  • To create a macOS bootable USB disk enter this command to your Terminal:
sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --nointeraction --downloadassets

Secondly, let Time Machine backup again and make sure you have this checklist ready:

  • The full Time Machine backup was finished.
  • The Brewfile and document with your settings were on either Dropbox or your backup drive.
  • The files you just backed up are ready to migrate back.

YOU ARE GOING TO DELETE EVERYTHING ON YOUR MAC IN THE NEXT STEP!!! You won’t be able to open your Mac until macOS is installed.

Lastly, start the format and re-installation process:

  • Plug in the bootable USB
  • Restart & hold down the Option(⌥) key
  • Choose Install OS X Sierra(the bootable USB)
  • Select Disk Utility from the menu and erase you Startup Disk(usually named Macintosh HD) with Mac OS Extended (Journaled)
  • Go back to the main menu; select Install macOS and choose your HDD when prompted
  • Continue installation with your credentials

Part III: Migration

First, we restore all software we had.

  • Open Terminal app then Install Homebrew via
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Copy the Brewfile to your home folder
  • Type brew bundle, if prompted, sign in your Apple ID for mas

Based on Brewfile we created eariler, Homebrew will automatically install all apps. During this time, you may migrate your static files back to your new Mac like the way you backup them. After apps installed completely, you migrate the software data back too. When all migration is done. CONGRATULATIONS! YOU’VE MADE IT! 🎉🎉🎉

References

  • I use this checklist to make sure everything’s been done correctly and will keep updated on GitHub, feel free to fork yourself.
  • I shared my Dotfiles on GitHub too, including my Brewfile. If you’re interested in Dotfiles, here is a sophisticated and well-documented version of Dotfiles by Zach Holman
  • If you are familiar with development tools and likely to automate everything, you may want to try Boxen.

Thank you for reading. If you liked this, 👏 it so other people will see this here on Medium.

--

--

David the Numb 

@rails developer, @apple enthusiast, live with my cat @_copythecat. opinions are my own. 4K resolution, 480p life.