背景
Mac的TimeMachine要求储存设备实现AFP,即Apple Filing Protocol,才能给Mac进行备份。所以自建一个AFP Server做备份。
目标
- 在Ubuntu上搭建AFP实现使用Mac TimeMachine备份
过程
先尝试一下用apt安装1
2
3
4 sudo apt install netatalk
安装完成以后查看一下版本号
afpd -v
afpd 2.2.5 - Apple Filing Protocol (AFP) daemon of Netatalk
只有2.2.5,而官网上最新的是3.1.10,所以果断卸载去从源码安装最新版。
依照官方教程安装必要的依赖1
2
3
4
5 sudo apt install build-essential libevent-dev libssl-dev libgcrypt20-dev libkrb5-dev \
libpam0g-dev libwrap0-dev libdb-dev libtdb-dev libmysqlclient-dev avahi-daemon \
libavahi-client-dev libacl1-dev libldap2-dev libcrack2-dev systemtap-sdt-dev libdbus-1-dev \
libdbus-glib-1-dev libglib2.0-dev libio-socket-inet6-perl tracker libtracker-sparql-1.0-dev \
libtracker-miner-1.0-dev
一共23个包,官方居然没有写成一条命令,看得眼睛痛。
然后下载源码,这里选择netatalk-3.1.10.tar.bz2。1
2
3
4
5
6
7 解压缩
tar xvf netatalk-3.1.10.tar.bz2
cd netatalk-3.1.10
列出帮助,看看如何配置,列在最后,方便以后复习
./configure --help
配置之前需要查看一下刚刚安装的tracker的版本,1.0无误。1
2
3 pkg-config --list-all | grep tracker
tracker-sparql-1.0 tracker-sparql - Tracker : A library to perform SPARQL queries and updates in the Tracker Store
tracker-miner-1.0 tracker-miner - A library to develop tracker data miners
开始配置,程序会自动检测,但是下面这些是不会的,所以需要自己根据情况指定,1
2
3
4
5
6
7
8
9
10 ./configure \
--with-init-style=debian-systemd \ #使用系统的初始化配置,16.04使用这个就行
--without-libevent \ #不使用bundle,不知道什么用,虽然刚刚好像下了这个包,既然是官网的先做个看
--without-tdb \ #同上
--with-cracklib \
--enable-krbV-uam \
--with-pam-confdir=/etc/pam.d \
--with-dbus-daemon=/usr/bin/dbus-daemon \
--with-dbus-sysconf-dir=/etc/dbus-1/system.d \
--with-tracker-pkgconfig-version=1.0
如果上面的输出没有什么错误的,那就可以开始安装了1
2
3
4
5 这一步我有多个warning,只要不是错误应该就行了
make
输出和上一步居然差不多,还以为有错
sudo make install
检查一下安装看看:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 netatalk -v
netatalk 3.1.10 - Netatalk AFP server service controller daemon
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version. Please see the file COPYING for further information and details.
netatalk has been compiled with support for these features:
Spotlight support: Yes
afpd: /usr/local/sbin/afpd
cnid_metad: /usr/local/sbin/cnid_metad
tracker manager: /usr/bin/tracker daemon
dbus-daemon: /usr/bin/dbus-daemon
afp.conf: /usr/local/etc/afp.conf
dbus-session.conf: /usr/local/etc/dbus-session.conf
netatalk lock file: /var/lock/netatalk
afpd -v
afpd 3.1.10 - Apple Filing Protocol (AFP) daemon of Netatalk
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version. Please see the file COPYING for further information and details.
afpd has been compiled with support for these features:
AFP versions: 2.2 3.0 3.1 3.2 3.3 3.4
CNID backends: dbd last tdb mysql
afp.conf: /usr/local/etc/afp.conf
extmap.conf: /usr/local/etc/extmap.conf
state directory: /usr/local/var/netatalk/
afp_signature.conf: /usr/local/var/netatalk/afp_signature.conf
afp_voluuid.conf: /usr/local/var/netatalk/afp_voluuid.conf
UAM search path: /usr/local/lib/netatalk//
Server messages path: /usr/local/var/netatalk/msg/
这样就没有问题了。
然后按照上面的AFP配置路径设置一下AFP Server:1
sudo vi /usr/local/etc/afp.conf
这里给出我自己的配置1
2
3
4
5
6
7
8[Global]
; Global server settings
hosts allow = 192.168.1.0/24
[My Time Machine Volume]
path = /mnt/timemachine/storage
time machine = yes
vol size limit = 170000
hosts allow
是可以访问的列表,我这样配置就只有接入了我的路由器的设备可以访问,上面中括号的里面的My Time Machine Volume
其实就是之后会显示出来的文件名,用time machine = yes
来告诉服务器,这个path需要启用time machine,vol size limit
可以用来限制使用多少空间,然后重启一下服务1
sudo service avahi-daemon restart
接下来就可以看到Mac里面会有一个以自己的服务器命名的设备了,连接以后即可,结果如下