I need to replicate a folder over a very slow link to several destinations.

Currently I create a text file with find.

find "$sourcedir" -exec ls -la {} \; > "$statefile"

I then compare it to a previous file created the same way to determine whether the script should exit or perform a few rsyncs. In the end the new statefile becomes the old statefile for next time the script runs.

if ! diff "$statefile" "$statefile".old 

Is there a better way minimising resource usage on source? (Compatible with bash on Debian.)

Should I just run the first rsynd and after changes, do the rest? How do I tell whether rsync has actually modified any files after the first rsync?

1 Answer 1


You want to reduce the resources used by find, ls and diff? Must be a huge amount of files for that becoming relevant I would guess...

You can obviously save a lot of ls calls by using -exec ... + instead of -exec ... ;. And you can consider getting rid of ls at all as it does nothing find cannot do itself. You may generate the file with find's printf values, creating more or less the same output. But: Neither ls nor find detect certain ACL and extended attribute changes.

A completely different approach: FAM (File Alteration Monitor). You let the kernel tell you (via e.g. fileschanged) what has (possibly) changed.

One more hint: Something like rdiff-backup should need less bandwidth than rsync because

  1. the checks are done locally
  2. the checks are done onyce only and not again for every target

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.