Would this be an OK substitute for rsync?

jjc_mn used Ask the Experts™
I can't load all the dependencies required for rsync because we don't want to mess with a production system.  Would this be an OK substitute script for rsync? It does a little over kill incase it can't run for a few days  but that's alright.  The main thing is I get all new files and directories and sub-directories copied to the dup location as well as modified files. I realize that removed stuff from the source doesn't go away in the dupdirectory but that should not happen in my particular case.

Will this work?  Any better idea?


cd sourcedirectory
tar cf - `find . -mtime -7 -type f`` | (cd /dupdirectory; tar xvf -)

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007
If rsync isn't an option, then your solution is not too bad.

Which particular dependencies are an issue for rsync?

Note that rsync is included on the Solaris 10 Companion CD/DVD.

You may also look at rdist (predecessor to rsync), it's included with older OS versions.
If you have a similar system where you can add the dependencies, build it there
and compile/load with static libs so it can be copied to the other system bringing
what it needs with the executable.
You could also use cpio which might be a better option than tar if you're copying across to different flavours of nix as its more argument portable, as opposed to different versions of tar which chop and change between versions more often. You'll need to feed it with find then pipe to ssh, but...a better solution than tar in my humble opinion if you dont want to go the tar/rsync route.

So...for example, you could set a date range with touch then feed that find into cpio and through to ssh:

find . -newer /tmp/file1 ! -newer /tmp/file2 -print | cpio -oaV | ssh user@host 'cpio -imVd'

Because you can be very specific with options and arguments with both find and cpio, this might be a better option in the long run. Obviously, have a play with all the valid suggestions given to you here, see which fits best for you.


Brian UtterbackPrinciple Software Engineer
Two things. Although I wouldn't normally recommend this, I am pretty sure that if you take the rsync binary from an opensolaris system, it will work on Solaris 10. The rsync in OpenSolaris is version 2.6.9 and doesn't have all the dependencies in later, externally built rsync programs.

The second is that if you are going from a Solaris to Solaris transfer, you might want to use cpio instead of tar. Although Sun tries to keep them in sync, new file system capabilities tend to be added to cpio first. It probably doesn't make a difference in most cases, but for making the two directories exactly the same cpio handles more file types.


Thanks for the suggestions

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial