If a file is on the destination box but not specified in the file given to --files-from option, shouldn't the file be deleted? Actual command: rsync -vrptgz --delete -l -P -e rsh --stats --bwlimit=120 --timeout=1600 --files-from=files.txt /src somebox:/src I want the files and directories under somebox:/src that are not listed in files.txt to be deleted. This is on AIX 5. (Perhaps this is a feature request?)
Nope, that's not how these options work. It might be interesting to add an option that would tell rsync to transform the piecemeal set of files and implied directories into a hierarchy of normal directories, but that can't be the default or it would break the more traditional uses of --files-from.
Another work around might be to allow a --max-size of zero combined with a --delete. --maxsize of zero is not supported in rsync. While it wouldn't completely solve the original problem, it will at least delete files on the receiver that are not in the senders directory without transferring anything. Thus one would do the original transfer first: -- rsync -vrptgz --delete -l -P -e rsh --stats --bwlimit=120 --timeout=1600 --files-from=files.txt /src somebox:/src --- followed by something like: -- rsync -rv --delete --max-size=0 -e rsh /src somebox:/src -- to get rid of extra files. Of course, files could still exist on the receiving side that in the senders directory tree that were not part of the --files-from list. But its a start. I supposed I could try to exclude everything (but then I'd need to learn about patterns :-).
(In reply to comment #2) > Another work around might be to allow a --max-size of zero combined with a > --delete. The recommended way to ask rsync to only delete files is to use the combination of --existing and --ignore-existing together so that rsync is skipping all file transfers and directory/symlink/device creations. There's also the script I just mentioned on the mailing list that turns a list of files into a set of includes & excludes that can be used in place of the --files-from option. The version from CVS is available here: http://rsync.samba.org/ftp/unpacked/rsync/support/files-to-excludes
It would be nice to have an option --delete-unlisted that causes the receiving rsync to delete extraneous files even from destination directories whose "contents" were not part of the transfer. The option would be as simple to implement as marking all directories with FLAG_DEL_HERE. Then Michael could use --delete-unlisted to "make --files-from delete".
Clarifying summary and bumping version (this feature still hasn't been added in 3.1.0dev).
*** Bug 7350 has been marked as a duplicate of this bug. ***
Any progress on this? An option to delete everything in DEST that isn't included in the transfer via something like a --delete-non-included option would make my life _so_ much easier. Since the workarounds are all varying degrees of ugly this is more than just a nice-to-have. I am trying to do: rsync -a --delete /a/b/ /c/d/e/ /f In /f I only want the contents of directories b and e and nothing else -- even if something else is already there. Also, the OS and hardware could probably be set to all since this is something that applies to all platforms.
Jeff: the command you mention already works fine, since --files-from is not involved.