Add Send_Backup

This commit is contained in:
Mattia Tadini 2024-11-19 13:20:21 +00:00
commit 6ac5c3da78

30
Send_Backup Normal file
View File

@ -0,0 +1,30 @@
##
## Automatically Backup For RouterOS With Export Config
##
##
## script by Mattia Tadini
## created: 2024-02-05
## updated: 2024-11-19
## tested on: RouterOS 7.16.1 / multiple HW devices, won't work on 6.49 and older (different update process & value naming)
##
:log info "Backup beginning now"
:global mail brass@relay.poloinformatico.it
:global getadate [/system clock get date]
:global backupfile (."BACKUP-". [/system identity get name] . "-" . [:pick $getadate 8 10 ] ."-". [:pick $getadate 5 7 ] . "-" . [:pick $getadate 0 4 ] )
:global exportrsc (."RSC-". [/system identity get name] . "-" . [:pick $getadate 8 10 ] ."-". [:pick $getadate 5 7 ] . "-" . [:pick $getadate 0 4 ] )
/export file=$exportrsc
:delay 10s
/system backup save name=$backupfile
:log info "Backup pausing for 10s"
:delay 10s
:global files {$backupfile;$exportrsc}
:log info "Backup being emailed"
/tool e-mail send to=$mail subject=("Backup RouterOS on router " . [/system identity get name] . " Backup " . [:pick $getadate 8 10 ] ."-". [:pick $getadate 5 7 ] . "-" . [:pick $getadate 0 4 ]) file=$files
:log info "Backup finished"