[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: exclude option for rsync



One little known feature of rsync is the fact that when run over a
remote shell (such as rsh or ssh) you can give any shell command as
the remote file list. The shell command is expanded by your remote
shell before rsync is called. For example, see if you can work out
what this does:

rsync -avR remote:'`find /home -name "*.[ch]"`' /tmp/

note that that is backquotes enclosed by quotes (some browsers don't
show that correctly).
not sure how to make this work.

Little-known indeed--I didn't know rsync could do that.. that's really cool.
So for a little more explanation, say you have a directory tree /database, and you want to sync only the files that were changed in the last ten days. You should be able to do something like the following:

rsync -av REMOTEHOST:'$(find /database -ctime -10)' /local/database/mirror
    which would be about the same as
rsync -av REMOTEHOST:'$(find /database -not -ctime +10)' /local/database/mirror

The difference between using find's ctime and mtime options: mtime will only change if the actual file data has changed, whereas ctime includes both file data and metadata--permissions, ownership info, file name, etc.

Hope that helps!

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]