macOS 使用 homebrew-bundle 优雅的备份和恢复软件列表

前言

每一个人都会积累一套本身习惯使用的 App。若是平时习惯使用 Time Machine 备份,那么在重装系统时,直接用它还原却是一个不错的办法,没必要再手动安装一个个 App。可是有些时候,咱们可能想要一个更加「干净」的新系统,此时就须要依次手动安装。这显然不是个高效、省心的方法,可能还须要一个个回忆以前用的 App。这时候,咱们每每但愿有一份属于本身的 App 清单,最好还能在重装时一键安装,省心省力。不管是Windows仍是macOS下咱们都但愿实现一键装机,而 homebrew-bundle 正是这样一款 Mac 下的备份恢复利器。java

macOS 使用 homebrew-bundle 优雅的备份和恢复软件列表

更新历史

2018年11月07日 - 初稿node

阅读原文 - https://wsgzao.github.io/post...python

扩展阅读mysql

按期自动云备份 macOS 软件列表,维护一份属于本身的必备 App 清单 - https://sspai.com/post/43265
狡兔三窟——云备份软件列表与相应配置,补充 Time Machine - https://sspai.com/post/43479git


Time Machine

macOS 自带的 Time Machine 无疑是备份与还原的利器。不管是重装系统,仍是新机配置,Time Machine 用起来都十分方便、省心。可是它存在如下不足:github

  1. 若是直接在本机硬盘上备份,Time Machine 动辄百 G 的硬盘占用,令小硬盘电脑用户望而却步。并且通常状况下,电脑内只有一块硬盘,若是系统和备份在同一硬盘上,那么硬盘挂了就二者皆挂。
  2. 若是使用网络备份,带宽和网络空间费用可能都是问题。
  3. 若是使用 NAS 或者使用树莓派架设 Time Capsule,则须要有必定的计算机相关基础和折腾能力。

即便上述状况对你来讲都不是问题,多一种备份方式也是多一份安全和保障。sql

homebrew-bundle

Bundler for non-Ruby dependencies from Homebrew

homebrew-bundle - https://github.com/Homebrew/h...shell

  1. Mac 上很是经常使用的包管理器 Homebrew, 咱们常常用它来安装其余的软件包
  2. 还有 Homebrew-cask, 能够用来安装图形界面的 App
  3. homebrew-bundle 相似 node 中的 package.json 或者 Cocoapods 中的 Podfile
  4. 咱们将须要的包和 App, 声明在一个 Brewfile 中, 而后执行 brew bundle 便可安装全部包

homebrew-bundle 如何备份

备份列表包含:express

  1. brew tap中的软件库
  2. brew 安装的命令行工具
  3. brew cask 安装的 App
  4. Mac App Store 安装的 App
# 执行brew bundle dump备份命令
brew bundle dump --describe --force --file="~/Desktop/Brewfile"

# 参数说明
--describe:为列表中的命令行工具加上说明性文字。
--force:直接覆盖以前生成的Brewfile文件。若是没有该参数,则询问你是否覆盖。
--file="~/Desktop/Brewfile":在指定位置生成文件。若是没有该参数,则在当前目录生成 Brewfile 文件。

# 该命令会在桌面上生成Brewfile文件,双击打开查看,其内容相似于

## 该部分是 brew 中的 tap,至关于一个个软件库
tap "homebrew/bundle"
tap "homebrew/cask"

## 该部分是 brew 安装的命令行工具
# Mac App Store command-line interface
brew "mas"
# UNIX shell (command interpreter)
brew "zsh"
# Fish shell like syntax highlighting for zsh
brew "zsh-syntax-highlighting"

## 该部分是 brew cask 安装的 app
cask "mounty"
cask "dteoh/sqa/slowquitapps"

## 该部分是 Mac App Store 安装的 app
mas "ting_en", id: 734383760
mas "Xcode", id: 497799835

homebrew-bundle 如何恢复

经过备份的软件列表文件批量安装软件
# 安装 Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# 安装 mas
brew install mas

# 批量安装软件
brew bundle --file="~/Desktop/Brewfile"

# 这里分享一份本身的真实备份文件
wangao@wangao-MAC ~/Desktop # cat Brewfile
tap "buo/cask-upgrade"
tap "dteoh/sqa"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
tap "homebrew/services"
# GNU compiler collection
brew "gcc"
# Distributed revision control system
brew "git", link: false
# Improved top (interactive process viewer)
brew "htop"
# Mac App Store command-line interface
brew "mas"
# MySQL database connector for C applications
brew "mysql-connector-c"
# Platform built on V8 to build network applications
brew "node"
# Perl compatible regular expressions library
brew "pcre"
# Password generator
brew "pwgen"
# Interpreted, interactive, object-oriented programming language
brew "python"
# Interpreted, interactive, object-oriented programming language
brew "python@2"
brew "sshpass"
# User interface to the TELNET protocol (built from macOS Sierra sources)
brew "telnet"
# Display directories as trees (with optional color/HTML output)
brew "tree"
# Internet file retriever
brew "wget"
# UNIX shell (command interpreter)
brew "zsh"
# Fish shell like syntax highlighting for zsh
brew "zsh-syntax-highlighting"
cask "java"
cask "mounty"
cask "xquartz"
cask "dteoh/sqa/slowquitapps"
mas "GarageBand", id: 682658836
mas "iMovie", id: 408981434
mas "Keynote", id: 409183694
mas "Microsoft Remote Desktop", id: 1295203466
mas "Numbers", id: 409203825
mas "Pages", id: 409201541
mas "ting_en", id: 734383760
mas "Xcode", id: 497799835
相关文章
相关标签/搜索