欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

a10 config backup for aXAPI

程序员文章站 2022-06-29 22:50:54
#!/bin/bash ################################################# # # script b...
#!/bin/bash 
################################################# 
# 
#   script by vincent yu 
#   created at 20140306 
#   a10 config backup for axapi version: 2.1 
# 
# 
################################################# 
a10ip="1.1.1.1 1.1.1.2"
user=admin 
password=a10 
today=`date "+%y%m%d"` 
backupdir=/path/$today 
timenow=`date "+%y%m%d%h%m"` 
log="/tmp/mail"
maillist="ng@ng.com.tw"
 for count in $a10ip do
 method1="method=authenticate&username=$user&password=$password"
 session=`curl -k --data $method1 https://$count/services/rest/v2.1/ | sed -n -e 's/.*\(.*\)<\/session_id>.*/\1/p'` 
 
 if [ ! -d $backupdir ];then
  mkdir -p $backupdir 
 fi
 
 gethost_m="session_id=$session&method=system.hostname.get"
 gethost=`curl -k https://$count/services/rest/v2.1/?$gethost_m | sed -n -e 's/.*\(.*\)<\/hostname>.*/\1/p'` 
 filename="$gethost-$timenow.tar.gz"
 backup_m="session_id=$session&format=json&method=system.backup"
 backup=`curl -k  https://$count/services/rest/v2.1/?$m -o $backupdir/$filename` 
 close_m="session_id=$session&method=session.close"
 close=`curl -k https://$count/services/rest/v2.1/?$close_m` done
 cd $backupdir echo "|----------- a10 system backup notification ------------------|" > $log echo " " >>$log ls -la *.gz | awk '{print $5,$6,$7,$8,$9}' >> $log echo " " >> $log echo "|------------------------------------------------------------------|" >>$log