Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 15172

Scripting • Re: Backup config to Gmail v1.6

$
0
0
Backup script to send config to Gmail account.
Code:
## Created Jotne 2023 v1.6## 1.6 Fixed script for x86 devicews (Credit rextended)# 1.5 Fixed for router missing serial# 1.4 Added Router OS version# 1.3r Revised by rextended# 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 "<your mail>@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 board ([resource get board-name]):local files "$rscfn.rsc,$bakfn.backup":local Version [resource get version]/system:local serial "undefined":if (!($board~"(x86|CHR)")) do={    :global testrbsn "NO RouterBOARD"    :execute ":global testrbsn; :set testrbsn [/system routerboard get serial-number]"    :delay 1s    :set serial $testrbsn    :set testrbsn} else={    :if ($board="x86") do={:set serial [license get software-id]}    :if ($board="CHR") do={:set serial [license get system-id]}}:if ($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 $Version $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"


----------------------------------------------------------------------------------------
Use Splunk> to log/monitor your MikroTik Router(s). See link below. :mrgreen:

MikroTik->Splunk
Thanks a lot for your script, sir!
Love this! Many thanks to you guys !

Statistics: Posted by joshhboss — Thu Feb 01, 2024 12:37 am



Viewing all articles
Browse latest Browse all 15172

Trending Articles