Guest User

Untitled

a guest
Apr 19th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.67 KB | None | 0 0
  1. #!/bin/bash
  2. #change list
  3. ##powercode billing server
  4. ##mysql login credentials
  5. ##community string to epmp radios
  6. ##email address to rx the backups
  7.  
  8. #this uses an ssh trust to the billing server
  9. #and ubntbackup sql user that can only access a few tables
  10. mkdir -p /opt/epmp-backup
  11. cd /opt/epmp-backup
  12.  
  13. ssh root@POWERCODE.BILLINGSERVER.COM 'echo "SELECT
  14.  INET_NTOA(e.IPAddress + a.StartAddress) AS '\''IP Address'\''
  15.  FROM Equipment e
  16.  LEFT JOIN AddressRange a ON e.IPType = a.AddressRangeID
  17.  INNER JOIN EquipmentEx ex ON ex.EquipmentID = e.ID
  18.  LEFT JOIN NetworkLocation nl ON nl.NetworkLocationID = ex.NetworkLocationID
  19. WHERE e.DeviceType IN ('\''Cambium ePMP AP'\'')" | mysql powernoc -uMYSQLUSERNAMEHERE -pMYSQLPASSWORDRIGHTHERE' > ipaddys.txt
  20.  
  21. sed -i '/IP Address/d' /opt/epmp-backup/ipaddys.txt
  22.  
  23. mkdir -p backups
  24.  
  25. communitystring=PUTYOURSTRINGRIGHTHEREANDMAKESUREITISGOOD
  26.  
  27. for IPADDR in $(<ipaddys.txt); do
  28. #asks radio to build backup and waits
  29. snmpset -v2c -c$communitystring $IPADDR 1.3.6.1.4.1.17713.21.6.4.30.0 i 001
  30. sleep 4
  31.  
  32. #checks if backup ready and gets it or touches file warning device was not ready for backup
  33. if [[ $(snmpget -O vq -v2c -c$communitystring  $IPADDR 1.3.6.1.4.1.17713.21.6.4.31.0) = 5 ]]; then
  34.   epmpbackupurl=$(snmpget -O vq -v2c -c$communitystring  $IPADDR 1.3.6.1.4.1.17713.21.6.4.33.0)
  35.   epmpbackupurl=$(sed -e 's/^"//' -e 's/"$//' <<<"$epmpbackupurl")
  36.   wget -q $epmpbackupurl -O backups/$IPADDR.bin
  37. else
  38.   touch backups/$IPADDR.NOTREADY
  39. fi
  40. done
  41.  
  42. #create tarball and email it out
  43. tar -cf epmp-backups.tar backups
  44. 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