rsync only files created or modified after a date and time

The goal is to rsync (or using any other tools that give the desired result) only files that are created or modified after a date. It should work with filenames containing spaces (and/or other characters that needs to escaped).

I succeeded using this command on OS X 10.6.5: find . -newermt "2010-11-23 16:52:50" -type f -exec rsync -vuptn '{}' ../rsync_test/ ';' I don't think -newermt is working on ohter OS than OS X though.

The problem with this command is that it runs rsync once per file found and that doesn't seems to be the proper way to do it. I tried to change the last ; with a + so it waits for the entire file list, but it brakes (I did try "+",\+ and other way to escape).

Background: I am trying to backup my files at a remote location. The files being a lot photos in raw and other format (photographs work. about 30GB per day), rsync'ing though the network would take unusable time due to small upload bandwidth (ADSL sucks). So the idea is to have a lot of disk space at a remote location and transporting new/modified files on a small external hard drive once a week. rsync can then easily be used to add the new/modified files at the remote location. For that I need to sync the new/modified files on an external hard drive during the week so I always have 2 copies of every files either at a remote location for files older than a week or on an external hard drive for new/modified files since the last transport.

I was going to make this command run every 10 minutes (cron) with the date and time from the last time it was run.

Can you fix my command? Or do you have an even better solution?


Solution 1:

I'm a little bit confused about what you're trying to do. Rsync, all by itself, will only transfer new/modified files. So if you transport data on a hard drive once/week, you can run rsync periodically and it will no more bandwidth than (and possibly less than) the solution you're proposing using find.

All this work with find seems like you're just duplicating features that are already there.

If you really want to use find, you don't need xargs or xargs-like features; just do this:

find ... -print | rsync ... --files-from=-

Where ... is "whatever other options you feel are appropriate". This causes rsync to read a list of files from stdin.