Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bitliner/c5bd783270c0efa6edb9c7192316670c to your computer and use it in GitHub Desktop.
Save bitliner/c5bd783270c0efa6edb9c7192316670c to your computer and use it in GitHub Desktop.

Revisions

  1. @JoeyBurzynski JoeyBurzynski revised this gist Mar 5, 2022. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -104,7 +104,7 @@ uninstall the apps, use the command: `brew bundle cleanup –force`
    #### Resources:

    - [brew bundle](https://github.com/Homebrew/homebrew-bundle.git)
    - [brew documentation (bundle subcommand)](https://docs.brew.sh/Manpagebundle-subcommand):
    - [brew documentation (bundle subcommand)](https://docs.brew.sh/Manpagebundle-subcommand)

    ## brew bundle (_man_)

  2. @JoeyBurzynski JoeyBurzynski revised this gist Mar 5, 2022. 1 changed file with 38 additions and 37 deletions.
    75 changes: 38 additions & 37 deletions Homebrew_How-to-Backup-and-Restore-Homebrew-Packages-2022.md
    Original file line number Diff line number Diff line change
    @@ -68,6 +68,44 @@ ability to restore applications when reinstalling macOS or setting up a new envi

    `$ brew bundle --help`

    ### Bundle Installation

    The first time the command, brew bundle, is run it will install, if not already.

    `brew bundle`

    ### Bundle Backup to Brewfile

    To create the Brewfile use the command, brew bundle dump, and a text file with all the Brew, Mac
    App Store apps, and their dependancies will be created in the current directory.

    `brew bundle dump`


    ### Bundle Check and List

    Using command, brew bundle check, will check to see if all dependancies are installed from the
    Brewfile. The command, brew bundle list, will list all the dependancies present in a Brewfile.

    - `brew bundle list`
    - `brew bundle check`

    ### Bundle Cleanup

    Using the command, brew bundle cleanup, will remove any apps installed, but not listed in the
    Brewfile.

    When the command, brew bundle cleanup, the output shows what will be uninstalled. To actually
    uninstall the apps, use the command: `brew bundle cleanup –force`

    - `brew bundle cleanup`
    - `brew bundle cleanup --force`

    #### Resources:

    - [brew bundle](https://github.com/Homebrew/homebrew-bundle.git)
    - [brew documentation (bundle subcommand)](https://docs.brew.sh/Manpagebundle-subcommand):

    ## brew bundle (_man_)

    ```bash
    @@ -236,40 +274,3 @@ By default, only Homebrew dependencies are listed.
    --zap: cleanup casks using the zap command instead of uninstall.
    ```
    ### Bundle Installation
    The first time the command, brew bundle, is run it will install, if not already.
    `brew bundle`
    ### Bundle Backup to Brewfile
    To create the Brewfile use the command, brew bundle dump, and a text file with all the Brew, Mac
    App Store apps, and their dependancies will be created in the current directory.
    `brew bundle dump`
    ### Bundle Check and List
    Using command, brew bundle check, will check to see if all dependancies are installed from the
    Brewfile. The command, brew bundle list, will list all the dependancies present in a Brewfile.
    - `brew bundle list`
    - `brew bundle check`
    ### Bundle Cleanup
    Using the command, brew bundle cleanup, will remove any apps installed, but not listed in the
    Brewfile.
    When the command, brew bundle cleanup, the output shows what will be uninstalled. To actually
    uninstall the apps, use the command: `brew bundle cleanup –force`
    - `brew bundle cleanup`
    - `brew bundle cleanup --force`
    #### Resources:
    - [brew bundle](https://github.com/Homebrew/homebrew-bundle.git)
    - [brew documentation (bundle subcommand)](https://docs.brew.sh/Manpagebundle-subcommand):
  3. @JoeyBurzynski JoeyBurzynski revised this gist Mar 5, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Homebrew_How-to-Backup-and-Restore-Homebrew-Packages-2022.md
    Original file line number Diff line number Diff line change
    @@ -271,5 +271,5 @@ uninstall the apps, use the command: `brew bundle cleanup –force`
    #### Resources:
    - brew bundle: https://github.com/Homebrew/homebrew-bundle.git
    - brew documentation (bundle subcommand): https://docs.brew.sh/Manpagebundle-subcommand
    - [brew bundle](https://github.com/Homebrew/homebrew-bundle.git)
    - [brew documentation (bundle subcommand)](https://docs.brew.sh/Manpagebundle-subcommand):
  4. @JoeyBurzynski JoeyBurzynski revised this gist Mar 5, 2022. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Homebrew: How to Backup & Restore Homebrew Packages [2022]
    # Homebrew: How to Backup & Restore Homebrew Packages

    Homebrew makes it easy to install and keep installed software up to date on your Mac - as part of my
    backup routine for my Mac I want to be able to run a single command to reinstall all packages.
  5. @JoeyBurzynski JoeyBurzynski created this gist Mar 5, 2022.
    275 changes: 275 additions & 0 deletions Homebrew_How-to-Backup-and-Restore-Homebrew-Packages-2022.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,275 @@
    # Homebrew: How to Backup & Restore Homebrew Packages [2022]

    Homebrew makes it easy to install and keep installed software up to date on your Mac - as part of my
    backup routine for my Mac I want to be able to run a single command to reinstall all packages.

    If you're searching on how to backup & restore Homebrew, then I assume you're here for the commands.

    ## Brewfiles

    Brewfiles are files generated with definitions that Homebrew reads and processes, a generated
    Brewfile looks similar to the below:

    ```
    tap "heroku/brew"
    tap "homebrew/bundle"
    tap "homebrew/cask"
    tap "homebrew/cask-versions"
    tap "homebrew/core"
    tap "homebrew/services"
    brew "borgmatic"
    cask "iterm2-beta"
    ```

    You can then run the following command to restore all taps, programs and cask-based applications in one go:

    `brew bundle`

    ## Backup

    Simply run the following command to set up the repository

    `brew tap Homebrew/bundle`

    Once complete, you can then perform a single command to backup to your home directory.

    `brew bundle dump`

    By default, the Brewfile will be located at `~/Brewfile`

    ## Restoring

    As mentioned before you can run the brew bundle command to restore from the backup but this will only restore from `~/Brewfile`

    You can use specific arguments to choose your Brewfile location

    ```
    brew bundle --help
    --file Read the Brewfile from this location. Use
    --file=- to pipe to stdin/stdout.
    Using --file will allow you to select different Brewfiles. An example of this can be selecting a
    file from a different snapshot.
    ```

    - Example: `brew bundle --file=~/Brewfile-20200531`


    ## Brew Bundle

    Per the Bundle github README, Bundler is a [1] “Bundler for non-Ruby dependencies from Homebrew,
    Homebrew Cask, Mac App Store(MAS) and Whalebrew.”

    Brew bundle creates a text file called Brewfile listing all the currently installed applications
    managed via Brew and the Mac App Store. This Brewfile can be used as a backup and gives you the
    ability to restore applications when reinstalling macOS or setting up a new environment.

    - Reference URL: https://docs.brew.sh/Manpagebundle-subcommand


    `$ brew bundle --help`

    ## brew bundle (_man_)

    ```bash
    Usage: brew bundle [subcommand]

    Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask, Mac App Store
    and Whalebrew.

    brew bundle [install]:
    Install and upgrade (by default) all dependencies from the Brewfile.

    You can specify the Brewfile location using --file or by setting the
    HOMEBREW_BUNDLE_FILE environment variable.

    You can skip the installation of dependencies by adding space-separated values
    to one or more of the following environment variables:
    HOMEBREW_BUNDLE_BREW_SKIP, HOMEBREW_BUNDLE_CASK_SKIP,
    HOMEBREW_BUNDLE_MAS_SKIP, HOMEBREW_BUNDLE_WHALEBREW_SKIP,
    HOMEBREW_BUNDLE_TAP_SKIP.

    brew bundle will output a Brewfile.lock.json in the same directory as the
    Brewfile if all dependencies are installed successfully. This contains
    dependency and system status information which can be useful in debugging brew
    bundle failures and replicating a "last known good build" state. You can
    opt-out of this behaviour by setting the HOMEBREW_BUNDLE_NO_LOCK environment
    variable or passing the --no-lock option. You may wish to check this file into
    the same version control system as your Brewfile (or ensure your version
    control system ignores it if you'd prefer to rely on debugging information from
    a local machine).
    brew bundle dump:
    Write all installed casks/formulae/images/taps into a Brewfile in the
    current directory.
    brew bundle cleanup:
    Uninstall all dependencies not listed from the Brewfile.
    This workflow is useful for maintainers or testers who regularly install lots of
    formulae.
    brew bundle check:
    Check if all dependencies are installed from the Brewfile.
    This provides a successful exit code if everything is up-to-date, making it
    useful for scripting.
    brew bundle list:
    List all dependencies present in the Brewfile.
    By default, only Homebrew dependencies are listed.
    brew bundle exec command:
    Run an external command in an isolated build environment based on the
    Brewfile dependencies.
    This sanitized build environment ignores unrequested dependencies, which makes
    sure that things you didn't specify in your Brewfile won't get picked up by
    commands like bundle install, npm install, etc. It will also add compiler
    flags which will help find keg-only dependencies like openssl, icu4c, etc.
    --file Read the Brewfile from this location. Use
    --file=- to pipe to stdin/stdout.
    --global Read the Brewfile from ~/.Brewfile.
    -v, --verbose install prints output from commands as they
    are run. check lists all missing
    dependencies.
    --no-upgrade install won't run brew upgrade on
    outdated dependencies. Note they may still be
    upgraded by brew install if needed.
    -f, --force dump overwrites an existing Brewfile.
    cleanup actually performs its cleanup
    operations.
    --cleanup install performs cleanup operation, same as
    running cleanup --force.
    --no-lock install won't output a
    Brewfile.lock.json.
    --all list all dependencies.
    --formula, --brews list Homebrew dependencies.
    --cask, --casks list Homebrew Cask dependencies.
    --tap, --taps list tap dependencies.
    --mas list Mac App Store dependencies.
    --whalebrew list Whalebrew dependencies.
    --describe dump adds a description comment above each
    line, unless the dependency does not have a
    description.
    --no-restart dump does not add restart_service to
    formula lines.
    --zap cleanup casks using the zap command
    instead of uninstall.
    -d, --debug Display any debugging information.
    -q, --quiet Make some output more quiet.
    -h, --help Show this message.
    ```
    ## bundle [subcommand]
    Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask, Mac App Store and Whalebrew.
    `brew bundle [install]`
    > Install and upgrade (by default) all dependencies from the Brewfile.
    You can specify the Brewfile location using --file or by setting the HOMEBREW_BUNDLE_FILE
    environment variable.
    You can skip the installation of dependencies by adding space-separated values to one or more of
    the following environment variables: `HOMEBREW_BUNDLE_BREW_SKIP`, `HOMEBREW_BUNDLE_CASK_SKIP`,
    `HOMEBREW_BUNDLE_MAS_SKIP`, `HOMEBREW_BUNDLE_WHALEBREW_SKIP`, `HOMEBREW_BUNDLE_TAP_SKIP`.
    brew bundle will output a Brewfile.lock.json in the same directory as the Brewfile if all
    dependencies are installed successfully. This contains dependency and system status information
    which can be useful in debugging brew bundle failures and replicating a “last known good build”
    state. You can opt-out of this behaviour by setting the HOMEBREW_BUNDLE_NO_LOCK environment
    variable or passing the --no-lock option. You may wish to check this file into the same version
    control system as your Brewfile (or ensure your version control system ignores it if you’d prefer
    to rely on debugging information from a local machine).
    `brew bundle dump`
    > Write all installed casks/formulae/images/taps into a Brewfile in the current directory.
    > `brew bundle cleanup`
    Uninstall all dependencies not listed from the Brewfile.
    This workflow is useful for maintainers or testers who regularly install lots of formulae.
    `brew bundle check`
    > Check if all dependencies are installed from the Brewfile.
    This provides a successful exit code if everything is up-to-date, making it useful for scripting.
    `brew bundle list`
    > List all dependencies present in the Brewfile.
    By default, only Homebrew dependencies are listed.
    `brew bundle exec command`
    > Run an external command in an isolated build environment based on the Brewfile dependencies.
    This sanitized build environment ignores unrequested dependencies, which makes sure that things you
    didn’t specify in your Brewfile won’t get picked up by commands like bundle install, npm install,
    etc. It will also add compiler flags which will help find keg-only dependencies like openssl,
    icu4c, etc.
    ```bash
    --file: Read the Brewfile from this location. Use --file=- to pipe to stdin/stdout.
    --global: Read the Brewfile from ~/.Brewfile.
    -v, --verbose: install prints output from commands as they are run. check lists all missing
    dependencies.
    --no-upgrade: install won’t run brew upgrade on outdated dependencies. Note they may still be
    upgraded by brew install if needed.
    -f, --force: dump overwrites an existing Brewfile. cleanup actually performs its cleanup
    operations.
    --cleanup: install performs cleanup operation, same as running cleanup --force.
    --no-lock: install won’t output a Brewfile.lock.json.
    --all: list all dependencies.
    --formula: list Homebrew dependencies.
    --cask: list Homebrew Cask dependencies.
    --tap: list tap dependencies.
    --mas: list Mac App Store dependencies.
    --whalebrew: list Whalebrew dependencies.
    --describe: dump adds a description comment above each line, unless the dependency does not have a
    description.
    --no-restart: dump does not add restart_service to formula lines.
    --zap: cleanup casks using the zap command instead of uninstall.
    ```
    ### Bundle Installation
    The first time the command, brew bundle, is run it will install, if not already.
    `brew bundle`
    ### Bundle Backup to Brewfile
    To create the Brewfile use the command, brew bundle dump, and a text file with all the Brew, Mac
    App Store apps, and their dependancies will be created in the current directory.
    `brew bundle dump`
    ### Bundle Check and List
    Using command, brew bundle check, will check to see if all dependancies are installed from the
    Brewfile. The command, brew bundle list, will list all the dependancies present in a Brewfile.
    - `brew bundle list`
    - `brew bundle check`
    ### Bundle Cleanup
    Using the command, brew bundle cleanup, will remove any apps installed, but not listed in the
    Brewfile.
    When the command, brew bundle cleanup, the output shows what will be uninstalled. To actually
    uninstall the apps, use the command: `brew bundle cleanup –force`
    - `brew bundle cleanup`
    - `brew bundle cleanup --force`
    #### Resources:
    - brew bundle: https://github.com/Homebrew/homebrew-bundle.git
    - brew documentation (bundle subcommand): https://docs.brew.sh/Manpagebundle-subcommand