Homebrew is a popular package manager for MacOS. It provides easy access to thousands of programs and applications. It is developed and maintained by an open-source community on Github. Use Homebrew bundle to backup and restore your Homebrew configuration.
If you haven’t installed it yet, go take a look quick on brew.sh or just install it by running the following command in the MacOS terminal.
1 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
The installation should succeed without problems. Installing some nice tools is also easy:
1 | brew install htop |
To install a better alternative to the standard process viewer top.
Brewfiles
This is where the magic happens. If you ever used npm, bower or another package-/assetsmanager you might be using dependency files that list a number of packages or assets that are to be installed. Brewfiles do about the same but then for your Homebrew configuration.
Let’s get started quickly! Install the Homebrew tap:
1 | brew tap Homebrew/bundle |
Dumping all of your Homebrew packages at once
Run the following command to create a text file named Brewfile with all Homebrew packaged installed on your system:
1 | brew bundle dump |
This creates a file with a lot of entries:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | tap 'caskroom/cask' tap 'homebrew/bundle' tap 'homebrew/core' tap 'homebrew/dupes' tap 'homebrew/php' tap 'homebrew/services' tap 'homebrew/versions' brew 'android-platform-tools' brew 'autoconf' brew 'boost' brew 'readline' brew 'calc' brew 'cscope' ... |
Keep this file safe in your cloud filestorage like Dropbox or e-mail.
1 | mv Brewfile ~/Dropbox |
Restore your configuration
Change your working directory to the folder containing the Brewfile. Then, to install/restore all items in the file, run:
1 2 | cd ~/Dropbox brew bundle |
Voilá! Homebrew starts reinstalling all packages.

Creating a custom Brewfile
The Brewfile syntax is easy. Each line is a command that gets executed. First, create an empty Brewfile:
1 | touch Brewfile |
Then – as an example – add a tap, a two brew packages and a cask respectively:
1 2 3 4 | tap 'homebrew/php' brew 'homebrew/php/php71', args: ['with-imap'] brew 'shpotify' cask 'spotify' |
Isn’t it nice?
Sponsored content