December 2006
Intermediate to advanced
1188 pages
72h 8m
English
You need to download all of the active router configurations to see what has changed recently.
The Perl script in Example 1-4 automatically retrieves and stores router configuration files on a nightly basis. By default, it retains these configuration files for 30 days. The script should be run through the Unix cron utility to get the automatic nightly updates, but you can also run it manually if required. No arguments are required or expected.
Example 1-4. backup.pl
#!/usr/local/bin/perl # # backup.pl -- a script to automatically backup a list of # router configuraton files on a nightly basis. # # # Set behavior $workingdir="/home/cisco/bkup"; $snmprw="ORARW"; $ipaddress="172.25.1.1"; $days="30"; # # $rtrlist="$workingdir/RTR_LIST"; $storage="$workingdir/storage"; $latest="$storage/LATEST"; $prev="$storage/PREV"; if (! -d $storage) {mkdir ($storage, 0755)}; if (! -d $prev) {mkdir ($prev, 0755)}; if (! -d $latest) {mkdir ($latest, 0755)}; ($sec, $min, $hr, $mday, $mon, $year, @etc) = localtime(time); $mon++; $year=$year+1900; $today1=sprintf("%.4d_%.2d_%.2d", $year, $mon, $mday); $today="$storage/$today1"; system("cp -p $latest/* $prev/"); unlink <$latest/*>; mkdir ($today, 0755); open (RTR, "$rtrlist") || die "Can't open $rtrlist file"; open (LOG, ">$workingdir/RESULT") || die "Can't open $workingdir/RESULT file"; print LOG "Router Configuration Backup Report for $year/$mon/$mday\n"; print LOG "======================================================\n"; ...Read now
Unlock full access