Miguel-Brbyte

Backup e Netwatch

Nov 19th, 2019 (edited)
647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. //Primeiro deve-se montar a URL do backup//
  2.  
  3. //subistituir X pelo IP de acesso do seu Controllr//
  4.  
  5. http://XXXXXXXXXX:8083/service/mikrotik/index?key=XXXXXXXXX&local_address=XXXXXXX&remote_address=XXXXXXXX
  6.  
  7. //Depois vá em System > Scripts
  8.  
  9. :global IPCONTROLLR "IPLOCALDOCONTROLLR";
  10. :global KEY "SUACHAVE";
  11. :global DEVICE "0";
  12. :global PPPOE "1";
  13. :global HOTSPOT "0";
  14. :global LOCALADDRESS "192.168.1.1";
  15. :global REMOTEADDRESS "pool-pppoe";
  16. :global DNSSERVER1 "8.8.8.8";
  17. :global DNSSERVER2 "8.8.4.4";
  18. :global done "";
  19. :log warning "Importando PPPoE";
  20. /tool fetch mode=http url="http://$IPCONTROLLR:8083/service/mikrotik/index?key=$KEY&device=$DEVICE&local_address=$LOCALADDRESS&remote_address=$REMOTEADDRESS&pppoe=$PPPOE&hotspot=$HOTSPOT&dns_server1=$DNSSERVER1&dns_server2=$DNSSERVER2" src-path=mikrotik.php dst-path=clientsctrl.rsc;
  21. :set done "true";
  22. :if ( [/file find name=clientsctrl.rsc] != "" ) do={
  23. :log warning "Importando PPPoE2";
  24. /import clientsctrl.rsc;
  25. /file remove clientsctrl.rsc
  26. #/ppp secret unset [find where comment=controllr] remote-address;
  27. /ppp secret set caller-id="" [find comment="controllr"]
  28. }
  29.  
  30. //Depois que substituir os campos corretos clique em Aplly e depois Run Script.
  31.  
  32. //Logo após rodar o Script, copie-o e cole em System > Scheduler, marque em Start Time : startup e Interval: 24:00:00
  33.  
  34. netwatch via script
  35.  
  36. /tool netwatch
  37. add comment=CTLR-BACKUP down-script=":log info \"IP do Controllr off habilitando as secrets\"\r\
  38. \n/ppp secret set [find comment=controllr] disabled=no" host=192.168.10.5 interval=2m up-script=":log info \"Desabilitando as Secrets do Controllr\"\r\
  39. \n/ppp secret set [find comment=controllr] disabled=yes\r\
  40. \n:delay 3m\r\
  41. \n:log info \"Removendo Secrets com o Comentario controllr\"\r\
  42. \n/ppp active remove [find where comment=controllr]"
  43.  
  44.  
  45.  
  46. #########################Build 2.0####################
  47.  
  48. {
  49. :global IPCONTROLLR "192.168.142.22";
  50. :global KEY "321351321";
  51. :global DEVICE "0";
  52. :global DHCP "1";
  53. :global PPPOE "0";
  54. :global HOTSPOT "0";
  55. :global IPMAC "0";
  56. :global WIRELESS "1";
  57. :global LOCALADDRESS "192.168.140.1";
  58. :global REMOTEADDRESS "pool-test-net";
  59. :global REMOTEBLOCK "pool-test-block";
  60. :global IPV6PXENA "pool-v6-px";
  61. :global IPV6PDENA "pool-v6-pd";
  62. :global DNSSERVER1 "8.8.8.8";
  63. :global DNSSERVER2 "8.8.4.4";
  64. :global done "";
  65. :global FILEPATH "controllr-backup.rsc";
  66. :log warning "CTLR - Iniciando Backup";
  67. :delay 3s;
  68. :if ([/file find name=$FILEPATH] != "") do={:log warning "CTLR - Apagando Backup Antigo $FILEPATH"; /file remove $FILEPATH;} else={:log warning "CTLR - Não existe nenhuma Backup antigo"};
  69. :delay 3s;
  70. :log warning "CTLR - Baixando Backup $FILEPATH";
  71. :delay 3s;
  72. /tool fetch mode=http url="http://$IPCONTROLLR:8083/service/mikrotik/backup?key=$KEY&device=$DEVICE&local_address=$LOCALADDRESS&remote_address=$REMOTEADDRESS&remote_block=$REMOTEBLOCK&ipv6_px_enable=$IPV6PXENA&ipv6_pd_enable=$IPV6PDENA&pppoe=$PPPOE&dhcp=$DHCP&hotspot=$HOTSPOT&ipmac=$IPMAC&wireless=$WIRELESS&dns_server1=$DNSSERVER1&dns_server2=$DNSSERVER2" src-path="$FILEPATH" dst-path="$FILEPATH";
  73. :delay 3s;
  74. :set done "true";
  75. :delay 3s;
  76. :log warning "CTLR - Conferindo Backup $FILEPATH";
  77. :delay 3s;
  78. :if ( [/file find name="$FILEPATH"] !="" ) do={:log warning "CTLR - Importando Backup $FILEPATH"; /import $FILEPATH; } else={:log warning "CTLR - Não tem num Backup de importacao, revise o script"};
  79. }
  80.  
  81.  
Add Comment
Please, Sign In to add comment