I need to keep in sync a very large directory structure (a few hundreds GB) between a Windows machine and a Linux machine. I'm using rsync to do the copy because it automatically ignores unchanged files and is more effective at copying changed files (copying only the difference).
The problem I have is that some applications running on the Windows file system like to generate all kinds of metadata files that I don't want to copy. As all these files are hidden using Windows file attributes, I thought it would be very helpful to simply instruct rsync to ignore such files. But the rsync man page does not offer any such option.
Currently I mount the Windows file system using SMB. When I use a console to list the files in the directory (using ls -l
), it lists all the files including hidden files, but when I use nautilus to list the files it recognizes that some are hidden files and only shows them to me if I enable "show hidden files". So I'm not sure if rsync can even see that Windows files are hidden.
Any suggestions will be really helpful.
To get the DOS attributes into Linux you will need to edit your smb.conf file.
There are two different ways to import Windows attributes.
The first option is to set
map hidden = yes
which will mean that hidden files on Windows will have the world execute bit set on Linux. For this to work you must also have at least001
in yourcreate mask
.The other option is to set
store dos attributes = yes
which will mean that the Windows attributes will be stored in an extended attribute in the Linux file system called user.DOSATTRIB.rsync
doesn't have the ability to filter files based on either normal or extended attributes but it can exclude a list of files that you have prepared in some other way. You can use thefind
command to create this list based on Unix attributes. The version offind
I have doesn't seem to support extended attributes but it might still be possible to use the-exec
option infind
to get extended attributes of all your files and filter on them.Since
find
can filter on normal Unix permissions, if you chose the world execute bit option thenfind . -perm -001
will find all of the hidden files in your mounted Windows filesystem. You can put this list in a file and then usersync --exclude-from=FILE
to exclude those files from your rsync.I don't believe rsync has any insight into which files are marked "Hidden" on the Windows fileshare. Do the files have anything else in common, such as a naming format? You can use the --exclude or --exclude-from options to pattern-match filenames not to copy. (The --exclude-from=xyz option loads these exceptions from a file, whereas the --exclude option specifies them on the command line.)
I don't have an answer for you, but I don't think rsync is the right place to be looking. I would either try to find something in the sharing options on the windows side, or a mount.cifs options.
It might be possible using ACL extensions, but there is nothing in traditional unix permissions that makes a file hidden. It is just hidden if has a period as the first character in the file / dir name.