[CentOS] Limiting files when using rsync

Mark Schoonover

schoon at amgt.com
Fri Jan 26 17:08:41 UTC 2007


Peter Serwe wrote:
> Todd Cary wrote:
>> Mark -
>> 
>> Thanks!  That did it.
>> 
>> /usr/bin/rsync -av --exclude=".*" -e ssh /home/ 192.168.0.22:/home/
>> My next step will be to brush the dust off of my Perl book and write
>> a crontab script to backup nightly.
>> 
>> Question: I may not be using the term "backup" absolutely correctly.
>> The destination server is a "standby" server.  This is if the source
>> server fails, all I have to do is change the router to point to the
>> standby server.  These are in a home office and I do not consider
>> myself a system administrator; just someone who knows enough to keep
>> the server running (it's main task is FTPing).  Do you have any
>> suggestions about using rsync as I am doing?
> I'm confused *what* in the world would make you want to write perl
> for this purpose when two lines of bash would serve the purpose
> (admirably). 
> 
> #!/bin/bash
> /usr/bin/rsync -av --exclude=".*" -e ssh /home/ 192.168.0.22:/home/
> 
> If for some reason, you wanted to do something sexier or more dynamic
> in terms of the source/destination, that would add 4 more lines to
> make it something like:
> 
> #!/bin/bash
> for dir in 'ls -1 /home/'
>      do
>      /usr/bin/rsync -av --exclude=".*" -e ssh /home/$dir/
> 192.168.0.22:/home/$dir/
>      done
> 
> You can even nest loops and iterate multiple parameters.
> 
> Peter

Peter,

	Was this just an example of using a for loop?? I wouldn't do this
with rsync, it can handle recursive directories on its own. Putting it in a
for loop, then calling rsync over and over again, will take a huge
performance hit because rsync will have to build the file list for each
directory in /home. Just point it to /home, and all will be fine.

Thanks!

Mark Schoonover
IS Manager
American Geotechnical
V: 858-450-4040 - F: 714-685-3909 - C: 858-472-3816

"Stop the Earth!! I want off!!"



More information about the CentOS mailing list