脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|shell|

服务器之家 - 脚本之家 - shell - a10 config backup for aXAPI

a10 config backup for aXAPI

2023-02-20 14:01脚本之家 shell

这篇文章主要介绍了Vincent yu 写的一个a10 config backup for aXAPI version: 2.1 ,需要的朋友可以参考下

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/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

延伸 · 阅读

精彩推荐