Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #change list
- ##powercode billing server
- ##mysql login credentials
- ##community string to epmp radios
- ##email address to rx the backups
- #this uses an ssh trust to the billing server
- #and ubntbackup sql user that can only access a few tables
- mkdir -p /opt/epmp-backup
- cd /opt/epmp-backup
- ssh root@POWERCODE.BILLINGSERVER.COM 'echo "SELECT
- INET_NTOA(e.IPAddress + a.StartAddress) AS '\''IP Address'\''
- FROM Equipment e
- LEFT JOIN AddressRange a ON e.IPType = a.AddressRangeID
- INNER JOIN EquipmentEx ex ON ex.EquipmentID = e.ID
- LEFT JOIN NetworkLocation nl ON nl.NetworkLocationID = ex.NetworkLocationID
- WHERE e.DeviceType IN ('\''Cambium ePMP AP'\'')" | mysql powernoc -uMYSQLUSERNAMEHERE -pMYSQLPASSWORDRIGHTHERE' > ipaddys.txt
- sed -i '/IP Address/d' /opt/epmp-backup/ipaddys.txt
- mkdir -p backups
- communitystring=PUTYOURSTRINGRIGHTHEREANDMAKESUREITISGOOD
- 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 4
- #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
- #create tarball and email it out
- tar -cf epmp-backups.tar backups
- uuencode epmp-backups.tar epmp-backups.tar| mail -s "epmp backups `date +%c`" PUTYOUREMAIL@ADDRESSRIGHTHERE.COM
Advertisement
Add Comment
Please, Sign In to add comment