RSYNC to windows CIFS copies all directories on update (but not old content)

cifsrsync

I have mounted a remote windows share (that will be where my backups to tape will be archiving).

I have 70GB of data that doesn't change that much, so I want to use RSYNC to mirror the data.

/usr/bin/rsync -rlptDv -e ssh --delete \
      --exclude "*Locks" --exclude "tmp" --bwlimit=0 \
      --modify-window=1 /cvs1/* localhost:/mnt/DUBBU01/Linux/Buzz/cvs1/

Now this works fine, in that no files are being updated. To be honest, the folder permissions done mean a damn, as these can be reset if i ever did have to restore from backup.

HOWEVER every single folder gets copied. Not their contents, just the folders. Is there a way to exclude folders containing data, but not the data itself?

The vast number of options in rsync is proving a pain to test this. And with about a million files, and a couple of hundred thousand directories, the ile build can take some time……

Best Answer

What you want to do should be possible with the --relative (or -R) option and a previous run of find to generate a file list:

find /cvs1 -type f -not \( -name *Locks -o -name tmp \) -print0 > filelist
rsync -pR --modify-window=1 -0 \
      --files-from=filelist /mnt/DUBBU01/Linux/Buzz/

Here you create a null-terminated list of files (only files, not directories) and feed this to rsync as the source for it's operation, informing it about the null-termination with -0. This is useful to avoid problems with spaces etc. in file names.


from the rsync man page:

   -R, --relative

Use relative paths. This means that the full path names specified on the command line are sent to the server rather than just the last parts of the filenames. This is particularly useful when you want to send several different directories at the same time. For example, if you used this command:

rsync -av /foo/bar/baz.c remote:/tmp/

... this would create a file named baz.c in /tmp/ on the remote machine. If instead you used

rsync -avR /foo/bar/baz.c remote:/tmp/

then a file named /tmp/foo/bar/baz.c would be created on the remote machine -- the full path name is preserved.