Total Pageviews

Sunday, 21 January 2024

使用 Mackup 快速备份 Mac 软件的配置文件

 

Mac 上备份数据资料,你会怎么做?想必很多人的选择都是使用系统内建的 Time Machine 来进行数据的备份与恢复。不过要知道,Time Machine 备份恢复的时间往往比较长,在这过程中还不一定会出什么意外。

如果你只需要备份 Mac 软件的配置文件,除了 Time Machine,你还可以试试 Github 上的开源项目 Mackup ,它拥有足够轻量与快速的备份恢复操作,更重要的是,它不需要另外安装,通过 Homebrew 与几行简单的命令就可以完成操作。

关于 Homebrew 的教程,请阅读:《借助 Homebrew Cask,教你快速下载安装 Mac App 新姿势》

关于 Mackup

Mackup 是 Github 上的一个开源项目,旨在帮助你快速方便地备份恢复软件的配置文件,Mackup 已经支持了包括 iTunes Applescripts 在内的一系列常用的软件程序,可以在它的项目首页进行更多了解。

除了开头介绍它是由命令行完成备份恢复操作之外,由 Mackup 备份的配置文件全部会存储在你的个人云端文件夹中,不会占用你的本地空间。目前 Mackup 支持的云端存储服务商有以下几种:

  • Dropbox
  • Google Drive
  • Copy
  • iCloud
  • Box

如果你不想用这些云服务的话,也可以用 Git 或其它在线工具存储。

安装 Mackup

1. 安装 Homebrew

上文提到了,Mackup 的安装可以通过 Homebrew 来完成,不了解 Homebrew 的朋友可以再看看之前的文章

简言之,你需要在终端中输入下列代码安装 Homebrew,如果你已经装过可忽略这一步:

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

2. 安装 Mackup

输入下面的命令安装 Mackup:

brew install mackup

3. 选择你的同步文件夹

Mackup 默认会将配置文件备份到你的 Dropbox 本地存储文件夹,前提是你的电脑上已经安装了 Dropbox。如果你不想存储到 Dropbox 中,那就需要稍微配置一下。

这里以 iCloud 为例,介绍 Mackup 的备份路径配置方法。

首先,在终端输入命令:

vi ~/.mackup.cfg

执行完上述命令之后,你会看到下面的界面.

不要慌张,继续在窗口中输入以下文字:

[storage]
engine = icloud

这样,你就已经设置好你的 Mackup 同步文件夹为 iCloud 了,剩下要做的就是保存这份配置文件:

按下「ESC」按键并输入 :wq 然后回车,至此,Mackup 的同步文件夹就已设置完成。

Mackup 的操作

关于 Mackup 的操作其实非常简单,这里列出 Mackup 的常用操作命令:

  • mackup backup 使用 Mackup 进行备份操作
  • mackup restore 使用 Mackup 进行数据的恢复
  • mackup list 查看 Mackup 支持的软件列表
  • mackup -h Mackup 的帮助命令
  • mackup uninstall 将配置文件拷贝回原来的系统目录

如果你想卸载 Mackup,输入以下命令即可:

brew uninstall mackup

from https://sspai.com/post/32933

---------

Keep your application settings in sync (OS X/Linux) 

Mackup

Keep your application settings in sync.

Table of content

Quickstart

If you have Dropbox installed and want to use it to save your config files, that's super easy.

On macOS, if you want an easy install, you can install Homebrew and do:

# Install Mackup
brew install mackup

# Launch it and back up your files
mackup backup

If not running macOS, or you don't like Homebrew, you can use pip.

Note: The below command will check if a previous version of Mackup is already installed on your system. If this is the case, it will be upgraded to the latest version.

# Install Mackup with PIP
pip install --upgrade mackup

# Launch it and back up your files
mackup backup

On Ubuntu, pip will install to the current user's home directory rather than system-wide. Because of this, when installing pip on Ubuntu you will need to run pip install with the --system flag as well (on other platforms this is not needed)

You're all set and constantly backed up from now on.

Next, on any new workstation, do:

# Install Mackup
brew install mackup

# Launch it and restore your files
mackup restore

Done!

You can find more detailed instructions in INSTALL.md.

Usage

mackup backup

Backup your application settings.

mackup restore

Restore your application settings on a newly installed workstation.

mackup uninstall

Copy back any synced config file to its original place.

mackup list

Display the list of applications supported by Mackup.

mackup -h

Get some help, obviously...

What does it do

  • Back ups your application settings in a safe directory (e.g. Dropbox)
  • Syncs your application settings among all your workstations
  • Restores your configuration on any fresh install in one command line

By only tracking pure configuration files, it keeps the crap out of your freshly new installed workstation (no cache, temporary and locally specific files are transfered).

Mackup makes setting up the environment easy and simple, saving time for your family, great ideas, and all the cool stuff you like.

Bullsh*t, what does it really do to my files

Let's take git as an example. Your settings for git are saved in your home folder, in the .gitconfig file.

Backup

If you have Dropbox, these things happen when you launch mackup backup:

  1. cp ~/.gitconfig ~/Dropbox/Mackup/.gitconfig
  2. rm ~/.gitconfig
  3. ln -s ~/Dropbox/Mackup/.gitconfig ~/.gitconfig

Now your git config is always backed up and up to date on all your workstations.

Restore

When you launch mackup restore, here's what it's really doing:

  1. ln -s ~/Dropbox/Mackup/.gitconfig ~/.gitconfig

That's it, you got your git config setup on your new workstation.

mackup does the same for any supported application.

Uninstall

You can revert all your files to their original state.

# Just run this
mackup uninstall

This will remove the symlinks and copy back the files from the Mackup folder in Dropbox to their original places in your home. The Mackup folder and the files in it stay put, so that any other computer also running Mackup is unaffected.

Supported Storages

See the README file in the doc directory for more info.

Unsupported Storages

  • Box: No longer supported as it ignores dotfiles, see #807.

from  https://github.com/lra/mackup/

 

 

 

No comments:

Post a Comment