#!/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 $A 10IP do method1= "Method=authenticate&username= $USER &password=$ PASSWORD "session= ' curl-k--data $METHOD 1 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 & Amp;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