Centos – rsync won’t write to mounted NFS share

centosnfspermissionsrsync

I am trying to run a simple rsync script from my CentOS server to copy files and folders to a mounted NFS share on my Synology NAS. The NFS share is mounted to the CentOS server fine. I can create files and browse it without problems from the CentOS server. I have the NFS share mounted at /mnt/nfs/synology.

The directory I am looking to copy is located at ~/resilio-sync/websites.
The rsync command is rsync -avz ~/resilio-sync/websites /mnt/nfs/synology
If I do a dry run it shows me what's going to be copied just fine.

sending incremental file list
websites/
websites/test.co.uk/
websites/test.co.uk/about.php
websites/test.co.uk/contact.php
websites/test.co.uk/dropbox_backup.sh
websites/test.co.uk/index.php
websites/test.co.uk/mailer.php
sent 6132 bytes  received 973 bytes  14210.00 bytes/sec
total size is 29217828  speedup is 4112.29 (DRY RUN)

When I try and run it for real I get this:

sending incremental file list
websites/
rsync: failed to set times on "/mnt/nfs/synology/websites": Operation not permitted (1)
websites/.sync/
rsync: recv_generator: mkdir "/mnt/nfs/synology/websites/.sync" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
websites/test.co.uk/
rsync: recv_generator: mkdir "/mnt/nfs/synology/websites/test.co.uk" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***

sent 5196 bytes  received 37 bytes  10466.00 bytes/sec
total size is 29217828  speedup is 5583.38
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1052) [sender=3.0.9]

I'm guessing it's telling me that it's permission related, but the strange thing is that I can write to both the source and destination directories just fine if I am not using rsync.

Any ideas what I am missing here?

Best Answer

The error output is telling you that you cannot write to the directory /mnt/nfs/synology/websites (i.e. you cannot create directories - and possibly even files - within it).

The dry run worked because it didn't actually attempt to transfer the files, and so it didn't encounter the permission problem.

If you're using sudo rsync... you will (almost certainly) find that sudo mkdir /mnt/nfs/synology/websites/test.co.uk also fails.


Incidentally, you'll get a far more efficient transfer if you enable the rsync service on the Synology NAS, and use that instead of transferring across NFS.

For starters, be aware that because you're using rsync to copy from one part of the local host's filesystem to another part of what looks like the local host's filesystem, it will not use its differential algorithm to transfer only changes to files' contents. Instead, it will look at file size and modification time and if they differ it will copy the file in its entirety.

Enabling the Synology NAS rsync service (or rsync over ssh if you can) will allow the tool to run in client-server mode, where it can check and transfer only changes to files.

Related Question