Machine A: Debian Testing (SparkyLinux 6) rsync 3.1.3
Machine B: Ubuntu Ubuntu 16.04.6, rsync 3.1.1

I have a bash script to backup a directory to a network connected machine. I have tried it both with backing up to a mounted directory (CIFS) or over rsync (rsync dameon run by root on target). Both filesystems are ext4. Both are mounted in fstab with RW,defaults.

My bash script checks for both directories existing and then runs (as root):

rsync -artzsv --force --delete --exclude=.Trash* --exclude=lost+found* /media/dcarrco/raid /media/bigdisk

Permissions on the source directory, for example, are:

drwxr-x---   8 dcarrco dcarrco 4.0K Feb  4  2013  dev  
-rw-rw-r--   1 dcarrco dcarrco  32G Nov  8 09:32  data.dat  
-rw-rw-r--   1 dcarrco dcarrco 114K Sep 22  2016  flower.jpeg

Once I run rsync (either on CIFS mounted directory or through the daemon) the target drive has:

drwxr-xr-x 2 dcarrco dcarrco    0 Feb  4  2013  dev  
-rwxr-xr-x 1 dcarrco dcarrco  32G Feb 14  2019  data.dat  
-rwxr-xr-x 1 dcarrco dcarrco 114K Sep 22  2016  flower.jpeg  

So the execute bits are now set on EVERY file it transferred. The next time I run rsync it transfers all those same files again (because the execute bit is NOT on the source and IS on the target).

So I tried deleting the directory on the target and just doing a fresh backup. Which worked. And then it (sigh) copied them all again the next time.

so i set the execute bit ON every file on the source. rsync copied nothing and said it was up to date.

I ran rsync with the --itemize-changes and it's just the executable bit on the files. Again and again. Any ideas?

EDIT: this ended up being a samba problem, not rsync. i don't know why rsync over the rsync daemon encountered the same problem but once i added file_mode=0644,dir_mode=0755 to my CIFS line in fstab, it worked as expected.

  • Have you tried adding --executability? Also, I'd recommend quoting the exclusions, to prevent the shell from expanding them before passing them to the rsync command. – Gordon Davisson Nov 9 at 6:06
  • i guess i was asking the wrong question. i thought it was an rsync thing, and its not. its a samba thing. i found strange behavior like listings on the target machine showed permissions correctly, but listings of the same directory on the share from the source machine showed execute bit set. so i unmounted the share and added file_mode=0644,dir_mode=0755 to my cifs line. now it works. thanks for the quote suggestion around my excludes, i have done that. – dcarrco Nov 9 at 17:20

It is samba server setting this x attribute. I don't remember the setting name but it may be related to mapping DOS system and/or hidden attributes or to forcing executable status of Windows files. Look into smb.conf man page.

BTW backing up Unix/Linux filesystem to CIFS filesystem is not the best idea IMHO. Can't you use NFS?

  • Tomek you are correct that the problem was samba. i added file_mode=0644,dir_mode=0755 to my CIFS fstab line and it works correctly. what i dont understand is why rsync over the rsync daemon had the same issue. doesnt the rsync daemon bypass samba? – dcarrco Nov 9 at 17:23
  • i use SMB because it allows the widest compatibility between all the devices accessing my server, mac laptops and windows laptops and fire tv stick and plex. i realize that samba is old and there are better options but im not quite good enough (yet) to get them all to work properly. also when i tried NFS one time i was struck by the seeming lack of security. – dcarrco Nov 9 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.