局域网内部署 SMB 服务器实现 macOS Time Machine 自动备份

参考链接: https://www.cnblogs.com/huoyanCC/p/17281882.html

最终效果: 使得 macOS 连上 WIFI 后能够自动通过局域网在目标服务器 (SMB 服务所在的服务器) 上进行「时间机器」的备份:

服务端设置

首先需要局域网内有固定 IP 的一台 Linux 主机, 这里我在 PVE 内开了一个 200GB 的虚拟机, 设置 IP 获取方式为静态, 发行版为 Debian 11.

apt update
apt install samba samba-vfs-modules
systemctl status smbd
vim /etc/samba/smb.conf

在该配置文件中插入如下内容:

[TimeMachineBackup]
   comment = macos time machine backup
   path = /tmachine
   browseable = yes
   read only = no
   writable = yes
   public = no
   # create mask = 0700
   guest ok = no
   vfs objects = fruit streams_xattr
   fruit:time machine = yes
   fruit:metadata = stream
   fruit:model = MacSamba
   fruit:veto_appledouble = no
   fruit:nfs_aces = no
   fruit:posix_rename = yes
   fruit:zero_file_id = yes
   fruit:wipe_intentionally_left_blank_rfork = yes
   fruit:delete_empty_adfiles = yes

重启服务并添加 SMB 用户和密码:

systemctl restart smbd
smbpasswd -a root # account that already exists in Linux

macOS 设置

首先通过 Finder 连接到 SMB 服务器上:

之后在 Time Machine 的设置中选择该位置作为备份所在处即可.