Backup and Restore your Homebrew Setup

Introduction

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.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Installing some nice tools is also easy:

brew install htop

Brewfiles

If you have ever used apt-get, dnf 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 the same for your Homebrew configuration.

Install the Homebrew tap:

brew tap Homebrew/bundle

This will dump 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:

brew bundle dump

This creates a file with a lot of entries:

tap "homebrew/bundle"
brew "bottom"
brew "coreutils"
brew "curl"
brew "duf"
brew "gh"
brew "git"
brew "htop"
brew "nano"
brew "neofetch"
brew "nmap"
brew "stow"
brew "tmux"
brew "tree"
brew "wget"
brew "zsh"
...

Save this file.

Restore your configuration

Change your working directory to the folder containing the Brewfile. Then to install/restore all items in the file, run:

brew bundle