Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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