Backup config to Gmail v1.7

Created Jotne 2022 v1.3r

1.3r Revised by REX

1.3 / 1.2 try to fix v6/v7 compability

1.1 added "show-sensitive"

1.0 initial release

Takes two different backup and send then to email

backup.rsc readable backup

Certificates, the Dude and Usermanager are also NOT exported or backed up fully and should be backed up separately

Can be used to restore config to different routers

backup.bin binary backup

Binary backup that can only be used to fully restored the same router.

{

:local email "@gmail.com"
:local rscfn "backup"
:local bakfn "bin"

/system
:local date [clock get date]
:local time [clock get time]
:local info [identity get name]
:local serial [routerboard get serial-number]
:local files "$rscfn.rsc,$bakfn.backup"

/system resource
:if ([get version]~"^7") do={
[:parse "/export show-sensitive file=$rscfn.rsc"]
} else={
/export file="$rscfn.rsc"
}
:delay 2s

/system backup save name="$bakfn"
:delay 2s

/tool e-mail send to="$email" subject="Mikrotik: Backup $info $serial" file="$files" body="Automatic Backup of $info $serial at $date $time"
:delay 20s
:execute "/file remove $files"
:log info "Backup router=$info serial=$serial ok"

}
Edit: put back the on :parse for v7 (invalid syntax but, thank to "if", never executed on v6)