Source: https://www.jafdip.com/how-to-setup-rsyncd-on-mac-os-x/
One of the most versatile utilities developed is rsync, however; learning to effectively use the application can be a daunting task. Rsync is useful for conducting backups to remote file servers or even mirroring a local drive to a removable one. It supports transferring files over ssh as well as it’s own protocol. Unfortunately, to use the built in rsync protocol you need to set up an rsync server, which on a Mac can be quite tricky.
On the one hand, you can simply type rsync —daemon and it will start a rsync daemon running on TCP port 873. But without the appropriate rsyncd.conf things can get a little messy. In addition, if you reboot the ‘server’ the process will not restart automatically. The worst thing is to have a system that has been operational for several months suddenly stop because someone rebooted the hardware and no one remembered that the process needed to be relaunched. Personally, I think it is much better to have the system offer some more resiliency by automating this process.
On the Mac, unfortunately inetd is no longer a viable option, thus you need to use launchd and launchdctl to load your XML described process file. So, I created the following plist (property list) file that I installed as root into /Library/LaunchDaemon.
Those instructions were tested on all versions of Mac OS from 10.3 to 11.0.
- (Optional) Install latest rsync and ignore Mac OS X rsync
brew install rsync - As privileged user, create a start-up configuration file
- First step is to open the file for edit...
- If using rsync from brew:
sudo vi /Library/LaunchDaemons/org.samba.rsync.plist - If using rsync shipped with macOS
sudo vi /Library/LaunchDaemons/rsync.plist - ...with the following contents
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>org.samba.rsync</string>
<key>Program</key>
<string>/usr/local/bin/rsync</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/rsync</string>
<string>--daemon</string>
<string>--no-detach</string>
<string>--verbose</string>
<string>--config=/usr/local/etc/rsyncd.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
</dict>
</plist> - Pay special attention to the highlighted text.
- Label (it appears twice):
- brew: org.samba.rsync
- Mac OS: rsync
- rsync path:
- brew: /usr/local/bin/rsync
- Mac OS: /usr/bin/rsync
- Configuration file:
- brew: /usr/local/etc/rsyncd.conf
- Mac OS X: /etc/rsyncd.conf
- As privileged user, create a configuration file
- Open file for edit...
- If using rsync from brew
sudo vi /usr/local/etc/rsyncd.conf - If using rsync shipped with macOS
sudo vi /etc/rsyncd.conf - with
hosts allow = 192.168.0.0/16
reverse lookup = false
list = yes
uid = nobody
gid = wheel
log file = /var/log/rsync.log
motd file = /usr/local/etc/rsyncd.motd
[Backup]
path = /Volumes/BackupVolume/BACKUPS/
comment = Backup area
read only = false
write only = false
use chroot = false
# max verbosity = 100
[vol014]
path = /Volumes/vol014
comment = Software area
read only = false
write only = false
use chroot = false
# max verbosity = 100
- Pay attention to the highlighted text
- My rsync server is limited to my internal network
- There is a specific log file for my rsync server
- macOS is based on FreeBSD. The root group is wheel, not root (like Linux).
- On connecting, the user receives a large screen message
- brew: /usr/local/etc/rsyncd.motd
- Mac OS X: /etc/rsyncd.motd
- As privileged user, create a Message-Of-The-Day file (/usr/local/etc/rsyncd.motd)
- My name:
https://www.patorjk.com/software/taag/#p=display&f=Big&t=ANDREAS%0ABERENDSEN%0A - Host name:
https://www.patorjk.com/software/taag/#p=display&f=Big&t=HG000005%0A -
brew:
sudo vi /usr/local/etc/rsyncd.motd -
Mac OS X:
sudo vi /etc/rsyncd.motd - with
==================================================================== 2020-Oct-07
_ _ _____ _____ ______ _____
/\ | \ | | __ \| __ \| ____| /\ / ____|
/ \ | \| | | | | |__) | |__ / \ | (___
/ /\ \ | . ` | | | | _ /| __| / /\ \ \___ \
/ ____ \| |\ | |__| | | \ \| |____ / ____ \ ____) |
/_/__ \_\_|_\_|_____/|_|__\_\______/_/ _\_\_____/__ _ _
| _ \| ____| __ \| ____| \ | | __ \ / ____| ____| \ | |
| |_) | |__ | |__) | |__ | \| | | | | (___ | |__ | \| |
| _ <| __| | _ /| __| | . ` | | | |\___ \| __| | . ` |
| |_) | |____| | \ \| |____| |\ | |__| |____) | |____| |\ |
|____/|______|_| \_\______|_| \_|_____/|_____/|______|_| \_|
UNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED
You must have explicit, authorized permission to access or configure this
device. Unauthorized attempts and actions to access or use this system may
result in civil and/or criminal penalties. All activities performed on this
device are logged and monitored.
Name : HG000007.local
Model Name : Mac mini
Model Identifier : Macmini7,1
Processor Name : Dual-Core Intel Core i5
Processor Speed : 1,4 GHz
Number of Processors : 1
Total Number of Cores : 2
L2 Cache (per Core) : 256 KB
L3 Cache : 3 MB
Boot ROM Version : 249.0.0.0.0
SMC Version (system) : 2.24f32
Serial Number (system): C07R11PZG1HV
Hardware UUID : F61F0D48-B3E7-5335-8EAB-5B93B8CF2BE0
Memory: 4GB (BANK 0/DIMM0: 2GB DDR3 1600 MHz)
(BANK 1/DIMM0: 2GB DDR3 1600 MHz)
Swap :
Disk :
/dev/disk0 (internal, physical): 2.0 TB
/dev/disk1 (synthesized) : 2.0 TB
/dev/disk2 (external, physical): 2.0 TB
/dev/disk3 (external, physical): 8.0 TB
/dev/disk4 (external, virtual) : 10.0 TB
Distro: Darwin Kernel Version 19.6.0 xnu-6153.141.1~1/RELEASE_X86_64 x86_64
ProductName: Mac OS X
ProductVersion: 10.15.6
BuildVersion: 19G2021
Network:
en0: 192.168.0.2/24 38:c9:86:30:35:8c Ethernet
en1: 192.168.1.28/24 bc:54:36:cd:a5:c4 Wi-fi
_ _ _____ ___ ___ ___ ___ ___ ______
| | | |/ ____|/ _ \ / _ \ / _ \ / _ \ / _ \____ |
| |__| | | __| | | | | | | | | | | | | | | | / /
| __ | | |_ | | | | | | | | | | | | | | | | / /
| | | | |__| | |_| | |_| | |_| | |_| | |_| |/ /
|_| |_|\_____|\___/ \___/ \___/ \___/ \___//_/
===================================================== /usr/local/etc/rsyncd.motd
- (Mac OS 10.15 & 10.14) Allow rsync to have access to the volumes. This is using the GUI. I am researching how to it form the command line.
- For Mac OS 10.15, 10.14
- System Preferences > Security & Privacy > Privacy > Full Disk Access
- Click the pad lock and type the admin (your user account) password
- Click the plus sign ("+") just below list box
- Navigate to /usr/local/bin/ and chose rsync
- Launch the rsync server
- If using rsync from brew
sudo launchctl load /Library/LaunchDaemons/org.samba.rsync.plist - If using rsync shipped with macOS
sudo launchctl load /Library/LaunchDaemons/rsync.plist - Check rsync is up and running
$ rsync --stats 192.168.0.5::
==================================================================== 2021-Jan-22
_ _ _____ _____ ______ _____
/\ | \ | | __ \| __ \| ____| /\ / ____|
/ \ | \| | | | | |__) | |__ / \ | (___
/ /\ \ | . ` | | | | _ /| __| / /\ \ \___ \
/ ____ \| |\ | |__| | | \ \| |____ / ____ \ ____) |
/_/__ \_\_|_\_|_____/|_|__\_\______/_/ _\_\_____/__ _ _
| _ \| ____| __ \| ____| \ | | __ \ / ____| ____| \ | |
| |_) | |__ | |__) | |__ | \| | | | | (___ | |__ | \| |
| _ <| __| | _ /| __| | . ` | | | |\___ \| __| | . ` |
| |_) | |____| | \ \| |____| |\ | |__| |____) | |____| |\ |
|____/|______|_| \_\______|_| \_|_____/|_____/|______|_| \_|
UNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED
You must have explicit, authorized permission to access or configure this
device. Unauthorized attempts and actions to access or use this system may
result in civil and/or criminal penalties. All activities performed on this
device are logged and monitored.
Name : HG000005.local
Model Name : Mac mini
Model Identifier : Macmini7,1
Processor Name : Dual-Core Intel Core i5
Processor Speed : 1,4 GHz
Number of Processors : 1
Total Number of Cores : 2
L2 Cache (per Core) : 256 KB
L3 Cache : 3 MB
Boot ROM Version : 249.0.0.0.0
SMC Version (system) : 2.24f32
Serial Number (system): C07R11PZG1HV
Hardware UUID : F61F0D48-B3E7-5335-8EAB-5B93B8CF2BE0
Memory: 4GB (BANK 0/DIMM0: 2GB DDR3 1600 MHz)
(BANK 1/DIMM0: 2GB DDR3 1600 MHz)
Swap :
Disk :
/dev/disk0 (internal, physical): 2.0 TB
/dev/disk1 (synthesized) : 2.0 TB
/dev/disk2 (external, physical): 2.0 TB
/dev/disk3 (external, physical): 8.0 TB
/dev/disk4 (external, virtual) : 10.0 TB
Distro: Darwin Kernel Version 19.6.0 xnu-6153.141.1~1/RELEASE_X86_64 x86_64
ProductName: Mac OS X
ProductVersion: 10.15.6
BuildVersion: 19G2021
Network:
en0: 192.168.0.2/24 38:c9:86:30:35:8c Ethernet
en1: 192.168.1.28/24 bc:54:36:cd:a5:c4 Wi-fi
_ _ _____ ___ ___ ___ ___ ___ ______
| | | |/ ____|/ _ \ / _ \ / _ \ / _ \ / _ \____ |
| |__| | | __| | | | | | | | | | | | | | | | / /
| __ | | |_ | | | | | | | | | | | | | | | | / /
| | | | |__| | |_| | |_| | |_| | |_| | |_| |/ /
|_| |_|\_____|\___/ \___/ \___/ \___/ \___//_/
===================================================== /etc/rsyncd.motd
drwxrwxrwx 748 2021/01/01 16:38:50 .
-rwxrwxrwx 24580 2021/01/22 14:44:36 .DS_Store
-rw-r--r-- 0 2020/10/17 01:34:43 .com.apple.timemachine.donotpresent
-rw-r--r-- 0 2020/11/17 09:49:17 .com.apple.timemachine.supported
-rw------- 181585142 2020/12/25 19:15:02 Projetos-20201225T180620Z-001.zip
-rw-r--r-- 178322 2020/12/17 21:54:08 apple_power_list.txt
drwxrwxrwx 272 2020/10/14 21:03:18 .DocumentRevisions-V100-bad-1
drwx------ 272 2020/11/27 19:54:09 .Spotlight-V100
drwxrwxrwt 136 2019/10/10 03:15:08 .TemporaryItems
d-wx--x--t 102 2020/12/23 06:08:41 .Trashes
drwx------ 238 2020/11/19 18:54:35 .finf
drwxrwxrwx 21114 2020/12/23 06:08:44 .fseventsd
drwxrwxrwx 1394 2020/10/29 12:57:15 Disc Images
drwxrwxrwx 1292 2020/11/25 18:32:44 Internet Mirrors
drwxr-xr-x 136 2020/11/03 18:27:23 Library
drwxr-xr-x 306 2020/11/07 14:22:10 Software Repository
drwxr-xr-x 136 2019/08/15 23:47:19 torrent_NB
Number of files: 17
Number of files transferred: 0
Total file size: 181788044 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 481
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 75
Total bytes received: 3065
sent 75 bytes received 3065 bytes 6280.00 bytes/sec
total size is 181788044 speedup is 57894.28
- Troubleshooting
- If not working, try to run the rsync from the command line while tailing the log files:
- In one terminal window (or tab), run
tail -f /var/log/rsync.log - In another terminal window (or tab), run the following command (the --port switch is to ensure that there are no security limitations on the server):
sudo /usr/local/bin/rsync -v -v -v -v -v --daemon --no-detach --config=/usr/local/etc/rsync.conf --port=5678 - From another terminal window (or tab), or another computer, run
rsync rsync://<your server-ip-or-name>:5678 - If you receive the motd message, then the problem can be the port or the plist file
Comments
Post a Comment