21:07 [ROS] Автобэкап на почту | |
Взято тут, спасибо тебе, добрый человек! При переходе на седьмую версию сэкономил кучу времени. { :log info "starting backup process..."; :local sysver [/system package get routeros version]; :local sysname [/system identity get name]; :local rbmodel [/system router get model]; :local rbuptime [/system resource get uptime]; /system clock :local date [get date]; :log info "flushing DNS cache..."; /ip dns cache flush; :delay 2; :log info "deleting latest backups..."; :foreach i in=[/file find] do={:if ([:typeof [:find [/file get $i name] "$sysname_"]]!="nil") do={/file remove $i}}; :delay 2; :log info "creating backup file..."; :local backupfile ("$sysname_" . "$date" . "_v$sysver" . ".backup"); /system backup save name=$backupfile; :delay 2; :log info "creating script file..."; :local exportfile ("$sysname_" . "$date" . "_v$sysver" . ".rsc"); /export show-sensitive file=$exportfile; :delay 2; :local files ($backupfile,$exportfile); :log info "sending files via email..."; /tool e-mail send to=mail@mail.com file=$files subject=("$rbmodel backup (" . [/system clock get date] . ")") body=("$sysname backup files are in the attachment.\nTime and Date: " . [/system clock get time] . " " . [/system clock get date] . "\n\nModel: $rbmodel\nRouterOS: $sysver\nUptime: $rbuptime"); :delay 4; :log info "...system backup completed"; } ROS 6.x - 7.9 { :log info "starting backup process..."; :local sysver [/system package get routeros version]; :local sysname [/system identity get name]; :local rbmodel [/system router get model]; :local rbuptime [/system resource get uptime]; :log info "flushing DNS cache..."; /ip dns cache flush; :delay 2; :log info "deleting latest backups..."; :foreach i in=[/file find] do={:if ([:typeof [:find [/file get $i name] "$sysname-"]]!="nil") do={/file remove $i}}; :delay 2; :log info "creating backup file..."; :local backupfile ("$sysname-" . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . "-v$sysver" . ".backup"); /system backup save name=$backupfile; :delay 2; :log info "creating script file..."; :local exportfile ("$sysname-" . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . "-v$sysver" . ".rsc"); /export show-sensitive file=$exportfile; :delay 2; :local files ($backupfile,$exportfile); :log info "sending files via email..."; /tool e-mail send to=mail@mail.com file=$files subject=("$rbmodel backup (" . [/system clock get date] . ")") body=("$sysname backup files are in the attachment.\nTime and Date: " . [/system clock get time] . " " . [/system clock get date] . "\n\nModel: $rbmodel\nRouterOS: $sysver\nUptime: $rbuptime"); :delay 4; :log info "...system backup completed"; } | |
|
Всего комментариев: 0 | |