Код:
#!/usr/bin/perl -w
open(CONFIG, "rsync_bakup.conf") or die "Config error: $1 \n";
while ($line = <CONFIG>) {
next if $line =~ /^#/;
next if $line eq "\n";
if ($line =~ /^\[/) {
chomp($line);
($line, ) = split("#", $line);
$line =~ s/\[|\]//g;
$block = $line;
}
else {
chomp($line);
($line, ) = split("#", $line);
$_=$line;
if (/user_name/) {
$line =~ s/user_name = //;
$user = $line;
}
elsif (/passwd_file/) {
$line =~ s/passwd_file = //;
$pass = $line;
}
elsif (/other_args/) {
$line =~ s/other_args = //;
$args = $line;
}
else {
($dest, $targ) = split(" = ", $line);
print "rsync "."--password-file=".$pass." ".$args." ".$user."\@".$block."\:\:".$dest." ".$targ."\n";
}
}
}Запускаем на windows:
Код: Выделить всё
E:\perl\rsync_bak>perl rsync.pl
rsync --password-file=/etc/rsyncd.pass -avu --delete backup@localhost::bin /mnt/backup/binЗапускаем на генте:
Код: Выделить всё
plab rsync_bak # rsync.pl
::bin /mnt/backup/bine=/etc/rsyncd.passПочему так?