Re: Rsync Script
by broomduster (Priest) on Aug 18, 2008 at 17:30 UTC
|
File::Rsync will do what you want. My experience with it is for relatively light and infrequent use, but it should do what you are asking without much fuss.
Update: The script that uses File::Rsync can handle the other book keeping chores you need (e.g., to avoid attempting to sync something that is already being sync'd). | [reply] [d/l] |
|
|
Thank you, but I'm already having a few issues just getting started with File::Rsync. First, it won't install on Windows manually or using the CPAN shell. Second, there don't appear to be many examples of it's use.
| [reply] |
|
|
File::Rsync will do what you want.
How? From the link you provide I get the impression File::Rsync just gives you an interface to rsync. The OP already knows rsync does most of it what he wants, and the little extra thing he wants, File::Rsync doesn't seem to provide.
| [reply] |
Re: Rsync Script
by Illuminatus (Curate) on Aug 18, 2008 at 19:54 UTC
|
Have you looked at the list method to rsync? You could use this to generate a list of files that need to be copied. I have not personally used this package, but it says that it returns a list with sizes. You could then split this list into n lists containing file totals of roughly equivalent sizes. You could then use scripts using rcp/scp to run through these lists, and have the main script harvest the children when they are finished. It is true that cron will not start a new copy of a job while the original is running, however if you set the interval to a small value, then it will still run within the next interval of when the last one finishes. Alternatively, you could use the 'at' queue, and have the job reschedule itself after completing. The code details are, of course, left as an exercise for the user :) | [reply] |
|
|
Hi Monk,
Did you find solution/script to get the functionality? If yes, will please share script with me?
| [reply] |
Re: Rsync Script
by NiJo (Friar) on Aug 18, 2008 at 19:20 UTC
|
Don't take requirements too serious. In many cases they are open for discussion and can be softened. In your case maybe "15 min if no big file" is all the author needs.
I'd not worry too much about running two instances at the same time. Even if you find a proper way of locking, the line will be blocked by the big file. Effectively that is another way of serialization. Rumor: Cron does not start a new script if the old instance is still running.
Contrary to most other unix tools rsync can do most things on its own. You should have found the --max-size option of rsync. I see little use for Perl in this project. If you really want Perl in the mix, rsnapshot might be your ultimate backup script. It uses rsync and keeps hard links between unchanged files. Basically you get full backups every time with disk space and network traffic of incrementals. | [reply] |
|
|
Yeah, this was sort of my thought, too.
If this was on *nix, I'd say look at bash to make this all work. I'm a little rusty on my Windows command-line stuff, but I'm pretty sure there's a way to see if there's an instance running. Or, of course, you could install cygwin and do it all from bash that way.
Really, though, if you hit Sourceforge, I'm pretty sure there are a bunch of front-ends for rsync that will run on Windows. Might be worth a look!
| [reply] |
Re: Rsync Script
by JavaFan (Canon) on Aug 18, 2008 at 18:30 UTC
|
It seems that all you need is a small program that first checks if there's already a copy of itself running, and exits if this is true. And if no copy is running, you call rsync.
Something like:
use Fcntl ':all';
my $lock = "/var/lock/whatever";
sysopen my $f, $lock, O_WRONLY | O_CREAT, 0644 or die;
flock $f, LOCK_EX | LOCK_NB or exit;
system 'rsync', ....;
__END__
| [reply] [d/l] |
|
|
Thanks, but how will that allow for multiple copies to run at the same time or for multiple threads?
| [reply] |
Re: Rsync Script
by dHarry (Abbot) on Aug 18, 2008 at 19:11 UTC
|
If you're happy with rsync then File::Rsync as suggested above is definitely worth a try. You could check the rsync resources. There are a few Perl scripts available there including the Perl wrapper mentioned above.
Maybe this is also a direction to look into: ftpsync. It acts as a primitive rsync clone. There are many solutions like this around.
Hope this helps
| [reply] |