@backupFiles = `ssh user\@backupserver ls /usr/local/apache/htdocs`;
####
while (1) {
do_something();
sleep 60;
}
####
my @files = map { "'$_'" }
grep {not $chompedList{basename($_)}
;
system "scp -C @files user\@backupserver:/usr/local/apache/htdocs";
####
#!/usr/bin/perl -W
use warnings 'all';
use strict;
my $rmthost = 'backupserver';
my $rmtuser = 'user';
my $rmtpath = '/usr/local/apache/htdocs';
my $lclpath = '/usr/myfiles';
my $lclglob = '*.htm';
my $flagfile = '.last_backup';
my $r_opts = "-azq --blocking-io -e 'ssh -l $rmtuser'";
my $lclfiles = "$lclpath/$lclglob";
sub modtime {
my $file = shift;
my @stats = stat $file or return 0;
return $stats[9];
}
while (1) {
my $timestamp = modtime("$lclpath/$flagfile");
my $run = grep {modtime($_) > $timestamp} glob $lclfiles;
if ($run) {
system "rsync $r_opts $lclfiles $rmthost:$rmtpath";
open FLAG, ">$lclpath/$flagfile" or die;
close FLAG or die;
}
sleep 60;
}