目前只在 2.6 上測試過,2.4 還有問題
fixed 20120918
can using in version 2.4 & 2.6
config.inc
<?php
#################################################
#
#
# carated date 20120904
# script by vincent yu
# for A10 backup script
#################################################
date_default_timezone_set("Asia/Hong_Kong");
$MYUSER="BackupA10UAER";
$MYPASSWD="1111111";
$REMOTE_SERVER="10.10.10.1";
$REMOTE_DIR="/home/BackupA10UAER";
// upload service 0=ftp ; 1=tftp
$UPLOAD_SERVICE="0";
$ary[0]['ip'] = "192.1.1.1";
$ary[0]['name'] = "TWa10-1";
$ary[1]['ip'] = "192.1.2.1";
$ary[1]['name'] = "TWa10-2";
$ary[2]['ip'] = "192.1.3.1";
$ary[2]['name'] = "BJa10";
/?>
- 說明 A
上面這是針對PHP5.3的日期函式的錯誤 "Asia/Hong_Kong" 這部分可以依照需求修改
It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function
- 說明 B
- 說明c
backup system,running-config & startup-config at the sunday
BackupA10.php
<?php
#################################################
#
#
# carated date 20120904
# script by vincent yu
# for A10 backup script
# verson 2.0
#################################################
include("config.inc");
function getStatusNew($XMLResult) {
preg_match('//', $XMLResult, $matches);
return isset($matches) ? $matches[1] : '';
}
$date1 = date("Ymd");
$type= date("N");
echo "type:".$type;
if ( $UPLOAD_SERVICE = "0" ){
$protocol="tftp";
$port="69";
}
elseif ( $UPLOAD_SERVICE = "1" ) {
$protocol="ftp";
$port="21";
}
for($i=0; $i $responseXML = file_get_contents($url);
//system config
echo $url3 = 'https://'.$ip.'/services/rest/V1/?session_id='.$session_id.'&method=system.config-file.upload&file-type=system&protocol='.$protocol.'&port='.$port.'&host='.$REMOTE_SERVER.'&save-filename='.$name.'_system-config_'.$date1.'.bk&file-format=text&username='.$MYUSER.'&password='.$MYPASSWD.'';
$responseXML = file_get_contents($url3);
}
else {
// running-config
echo $url = 'https://'.$ip.'/services/rest/V1/?session_id='.$session_id.'&method=system.config-file.upload&file-type=running-config&protocol='.$protocol.'&port='.$port.'&host='.$REMOTE_SERVER.'&save-filename='.$name.'_runing-config_'.$date1.'.bk&file-format=text&username='.$MYUSER.'&password='.$MYPASSWD.'';
$responseXML = file_get_contents($url);
// startup-config backup
echo $url2 = 'https://'.$ip.'/services/rest/V1/?session_id='.$session_id.'&method=system.config-file.upload&file-type=startup-config&protocol='.$protocol.'&port='.$port.'&host='.$REMOTE_SERVER.'&save-filename='.$name.'_startup-config_'.$date1.'.bk&file-format=text&username='.$MYUSER.'&password='.$MYPASSWD.'';
$responseXML = file_get_contents($url2);
//system config
echo $url3 = 'https://'.$ip.'/services/rest/V1/?session_id='.$session_id.'&method=system.config-file.upload&file-type=system&protocol='.$protocol.'&port='.$port.'&host='.$REMOTE_SERVER.'&save-filename='.$name.'_system-config_'.$date1.'.bk&file-format=text&username='.$MYUSER.'&password='.$MYPASSWD.'';
$responseXML = file_get_contents($url3);
}
// close session
$responseXML = file_get_contents('https://'.$ip.'/services/rest/V1/?session_id='.$session_id.'&method=session.close');
}
?>
使用方式 /usr/sbin/php BackupA10.php 放到crontab裡
ref doc AX_aXAPI_Ref_v2_4_3-20110318.pdf
張貼留言