我正在尝试使用rsync和sftp建立从ubuntu服务器到Synology NAS(DS413j)的备份系统.
我为此创建了一个用户,我们可以调用ubuntu-backup.
我在ubuntu-backup主目录中有一个名为www的目录,其中将保存备份.
我在DSM中启用了网络备份
用户ubuntu-backup可以完全访问它的主目录
这是我在Synology NAS上的rsync配置文件:
#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/ ubuntu-backup@backup.example.com:./
结果:
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/ ubuntu-backup@backup.example.com
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/ ubuntu-backup@backup.example.com:./
要么
rsync -aHvhiPb "ssh -l ubuntu-backup" /var/www/ backup.example.com:./
rsync的手册页中有很多例子.
在第二个示例中,它将文件同步到位于direct中的名为ubuntu-backup@backup.example.com的目录中.为了指定远程服务器,您应该在规范中的某处使用冒号.