Search code examples
file-permissionsrsync

Rsync: skip files with sticky bit set


I am backing up an ext4 disk on Linux where some files have zero length and these funny permissions:

---------T. 2 myuser mygroup 0 Mar 5 2019 filename

From what I understand, they are leftovers from a previous glusterfs running on that disk, and can be safely skipped when copying the data. But rsync gives me this generic error, probably because of the missing read permission:

rsync: send_files failed to open "filename": Permission denied (13)

How can tell rsync to skip these files, based on the sticky bit set? I'd like to separate these from other possible problems with file permissions.


Solution

  • rsync does not seem to have anything specifically to handle this case, but what you can do is construct a list of files to exclude by using find beforehand. For example:

    find dir -type f ! -perm /777 >list
    rsync -a --exclude-from=list dir destdir
    

    -perm /777 finds files with at least one bit set in the modes 777, and ! negates this.