树莓派3b上外接了一块硬盘,加上resilio-sync来做同步,备份文件。
vim /etc/systemd/system/opt-sync.mount
,文件名是目录+.mount
[Unit]
Description=My flashdrive script trigger
#Requires=.mount
#After=media-YourMediaLabel.mount
After=usb_modeswitch@.service
#[Service]
#ExecStart=/home/you/bin/triggerScript.sh
[Mount]
#What=UUID=ea8d7bf8-384d-412b-b9eb-b92f702fc360
What=/dev/sda2
Where=/opt/sync
#Options=nofail
Type=ext4
[Install]
WantedBy=multi-user.target
开机自动挂载systemctl enable opt-sync.mount
编辑sync的systemd配置文件,确保在挂载了usb硬盘后启动
vi /lib/systemd/system/resilio-sync.service
[Unit]
Description=Resilio Sync service
Documentation=http://help.getsync.com/
#opt-sync.mount是后增加的,确保在挂载了usb硬盘后,resilio-sync才启动
After=network.target network-online.target opt-sync.mount