This generally works for some devices. Unfortunately it seems some (random?) ones won't get the backup built in time, even after 30 seconds. I'm wondering if there's a better option than increasing the sleep time to something like 60/90/120+ seconds. What is everyone else doing for backups?
for IPADDR in $(<ipaddys.txt); do #asks radio to build backup and waits snmpset -v2c -c$communitystring $IPADDR 1.3.6.1.4.1.17713.21.6.4.30.0 i 001 sleep 30
#checks if backup ready and gets it or touches file warning device was not ready for backup if [[ $(snmpget -O vq -v2c -c$communitystring $IPADDR 1.3.6.1.4.1.17713.21.6.4.31.0) = 5 ]]; then epmpbackupurl=$(snmpget -O vq -v2c -c$communitystring $IPADDR 1.3.6.1.4.1.17713.21.6.4.33.0) epmpbackupurl=$(sed -e 's/^"//' -e 's/"$//' <<<"$epmpbackupurl") wget -q $epmpbackupurl -O backups/$IPADDR.bin else touch backups/$IPADDR.NOTREADY fi done
You can poll the backup status OID until it returns something useful or times out; I've taken the liberty of whipping up some code for you as it's probably quite useful to me too.
This will request the config backup, wait 10s, and then poll every 10s for backup status until either 2 minutes (12 attempts) are up or it succeeds/fails (based on the backup status MIB)
CommunityString="private"
for IPADDR in $(<ipaddys.txt); do #Ask for backup to be built, reset retry counter, wait 10s for first try
snmpset -v2c -OvQ -mCAMBIUM-PMP80211-MIB -c${CommunityString} ${IPADDR} cambiumFullCfgBackUp.0 i 001 2>&1 1>/dev/null
BKtries=1
sleep 10
#checks update status every 10s until response or 12 tries (2min)
while true; do
#poll
epmpBackupStatus=$(snmpget -v2c -OvQ -mCAMBIUM-PMP80211-MIB -c${CommunityString} ${IPADDR} cambiumFullCfgBackUpStatus.0 2>&1)
#process response
case "$epmpBackupStatus" in
5)
#backup done, grab URL and download
epmpBackupURL=$(snmpget -Ovq -v2c -mCAMBIUM-PMP80211-MIB -c${CommunityString} ${IPADDR} cambiumFullCfgBackUpLink.0 2>&1)
epmpBackupURL=$(sed -e 's/^"//' -e 's/"$//' <<<"$epmpBackupURL")
wget -q $epmpBackupURL -O backups/$IPADDR.bin
echo "Backed up ${IPADDR} to backups/${IPADDR}.bin after ${BKtries} attempts"
break
;;
-1)
#error detected; pull error;
epmpBackupError=$(snmpget -Ovq -v2c -mCAMBIUM-PMP80211-MIB -c${CommunityString} ${IPADDR} cambiumFullCfgBackUpError.0 2>&1)
echo ${epmpBackupError} > backups/$IPADDR.ERROR
echo "ERROR while backing up ${IPADDR} ${ePMPBackupError} stored in backups/${IPADDR}.ERROR"
#exit while loop
break
;;
*)
#any other option - check retries, error out if too many
if [[ ${BKtries} -gt 12 ]]; then
epmpBackupError="Retry count exhausted"
echo ${epmpBackupError} > backups/$IPADDR.ERROR
echo "ERROR while backing up ${IPADDR}; ${ePMPBackupError} stored in backups/${IPADDR}.ERROR"
#exit while loop
break
else
#increment counter, wait 10s
(( BKtries++ ))
sleep 10
fi
;;
esac
done
done
Should work - based on similar code I use for firmware updates.
I love the QOL improvements!!! The echo I need to either log or or /dev/null as I run this in cron so I get email updates, but otherwise it's absolutely beautiful.