maybe someone find it useful:
-----------------------------------------------
#!/usr/bin/perl
use strict;
my %conf;
$conf{proto}="https";#should be ok
$conf{user}="admin"; #edit here if needed
$conf{rm}="/bin/rm -rf";
$conf{mkdir}="/bin/mkdir";
$conf{curl}="/usr/bin/curl -k -s -o";
#ok I know -k is not very god but its quick and dirty
$conf{args}="-F Submit=download -u $conf{user}:";
$conf{base}="/home/afe/m0n0bak"; #change this
#put all your m0n0s in here!
$conf{conf}=
{
COSTUMER1=>{host01=>'192.168.0.1:password'},
};
#in this example COSTUMER1 is the name of my costumer
#host01 is DNS name
#last the ip and the password seperated by a ':'
#Wondering why I use IP and DNS?
#somtimes it could happen that dns does not work...
#here is a more complex example
#$conf{conf}=
# {
# COSTUMER1=>{
# host01=>'192.168.0.1:password1'
# host02=>'192.168.0.2:password2'
# host03=>'192.168.0.3:password3'
# host04=>'192.168.0.4:password4'
# host05=>'192.168.0.5:password5'
# },
# COSTUMER2=>{host01=>'192.168.0.1:password'},
# };
system("$conf{rm} $conf{base}");
system("$conf{mkdir} $conf{base}");
chdir $conf{global}{base};
for(sort keys %{$conf{conf}}){
my $costumer=$_;
print " Doing backup for costumer:$costumer\n";
system("/bin/mkdir $conf{base}/$costumer");
chdir "$conf{base}/$costumer";
for(sort keys %{$conf{conf}{$costumer}}){
my $host=$_;
my ($ip,$pw)=split /:/,$conf{conf}{$costumer}{$host};
print "Donwloading config from host:$host\/ip:$ip\n";
my $filename ="config-$host.xml";
my $uri="$conf{proto}://$ip/diag_backup.php";
system("$conf{curl} $filename $conf{args}:$pw $uri\n");
print "Download of configfile $filename complete..\n";
}
}
------------------------------------------------------------------
TODO:
-Errorhandling
-Logfile
-CA handling for curl
regards
Andreas
--
STASOFT AG
P: +41 61 726 80 70
F: +41 61 726 80 79 |