我试图使用rsync和sftp从Ubuntu服务器到Synology NAS(DS413j)build立一个备份系统。
我为此创build了一个用户,我们可以调用ubuntu-backup。 我有一个名为www的ubuntu-backup主目录中的一个目录,备份将被保存。 我已经在DSM中启用networking备份用户ubuntu-backup可以完全访问它的主目录
以下是Synology NAS上的rsyncconfiguration文件:
#motd file = /etc/rsyncd.motd #log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock use chroot = no [NetBackup] path = /var/services/NetBackup comment = Network Backup Share uid = root gid = root read only = no list = yes charset = utf-8 auth users = root secrets file = /etc/rsyncd.secrets [ubuntu-backup] path = /volume1/homes/ubuntu-backup/www comment = Ubuntu Backup uid = ubuntu-backup gid = users read only = false auth users = ubuntu-backup secrets file = /etc/rsyncd.secrets
/ volume1 / homes / ubuntu-backup / www上的权限是ubuntu-backup:users 777
这是我正在运行的命令。
rsync -aHvhiPb /var/www/ [email protected]:./
结果:
sending incremental file list ERROR: module is read only rsync error: syntax or usage error (code 1) at main.c(1034) [Receiver=3.0.9] rsync: connection unexpectedly closed (9 bytes received so far) [sender] rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]
如果我运行这个:
rsync -aHvhiPb /var/www/ [email protected]
它看起来像它的发送文件。 没有错误。 但是我无法在NAS上find任何东西。
rsync不会执行SFTP。 从手册页:
There are two different ways for rsync to contact a remote system: using a remote-shell program as the transport (such as ssh or rsh) or contacting an rsync daemon directly via TCP.
SFTP不给你一个shell,但它不适用于rsync。 您将需要一个SSH连接。
一旦你允许SSH连接,你可能需要专门告诉rsync使用SSH。 有几种方法可以做到这一点:
rsync -aHvhiPb --rsh=ssh /var/www/ [email protected]:./
要么
rsync -aHvhiPb "ssh -l ubuntu-backup" /var/www/ backup.example.com:./
在rsync的手册页中有更多的例子。
在第二个示例中,它将文件同步到直接位于名为[email protected]的目录中。 为了指定远程服务器,你应该在规范中的某个地方使用冒号。