{"id":396,"date":"2021-12-07T07:48:43","date_gmt":"2021-12-07T07:48:43","guid":{"rendered":"https:\/\/sznetwork.systems\/?p=396"},"modified":"2025-05-27T15:46:00","modified_gmt":"2025-05-27T13:46:00","slug":"mikrotik-send-backup-files-to-email","status":"publish","type":"post","link":"https:\/\/sznetwork.systems\/?p=396","title":{"rendered":"Mikrotik Send Backup Files to Email (Migrated)"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">Script for Mikrotik to send frequently backup files to email<\/pre>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"How to frequently send backup files from Mikrotik to email, through script\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/uxfo5zescgI?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">\nWinbox already is connected.<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.1-1024x555.jpg\" alt=\"\" class=\"wp-image-398\" srcset=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.1-1024x555.jpg 1024w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.1-300x163.jpg 300w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.1-768x416.jpg 768w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.1-1536x832.jpg 1536w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.1.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre id=\"block-6a938f36-3293-49e5-9c24-ea359e226213\" class=\"wp-block-preformatted\">First we go to the section System, Scripts<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.2-1024x555.jpg\" alt=\"\" class=\"wp-image-399\" srcset=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.2-1024x555.jpg 1024w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.2-300x163.jpg 300w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.2-768x416.jpg 768w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.2-1536x832.jpg 1536w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.2.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">Press ADD, new script.<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.3-1024x555.jpg\" alt=\"\" class=\"wp-image-400\" srcset=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.3-1024x555.jpg 1024w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.3-300x163.jpg 300w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.3-768x416.jpg 768w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.3-1536x832.jpg 1536w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.3.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">Fill name of script. \nFill script.<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Script<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>:log info \"Starting Backup Script...\";\n:local sysname [\/system identity get name];\n:local sysver [\/system package get system version];\n:log info \"Flushing DNS cache...\";\n\/ip dns cache flush;\n:delay 2;\n:log info \"Deleting last Backups...\";\n:foreach i in=[\/file find] do={:if ([:typeof [:find [\/file get $i name] \\\n\"$sysname-backup-\"]]!=\"nil\") do={\/file remove $i}};\n:delay 2;\n:local smtpserv [:resolve \"smtp.gmail.com\"];\n:local Raccount \"gageyo6314@suggerin.com\";\n:local Eaccount \"simplelbase@gmail.com\";\n:local pass \"pljifpfojvrdoodm\";\n:local backupfile (\"$sysname-backup-\" . \\\n[:pick [\/system clock get date] 7 11] . [:pick [\/system \\\nclock get date] 0 3] . [:pick [\/system clock get date] 4 6] . \".backup\");\n:log info \"Creating new Full Backup file...\";\n\/system backup save name=$backupfile;\n:delay 2;\n:log info \"Sending Full Backup file via E-mail...\";\n\/tool e-mail send from=\"&lt;$Eaccount>\" to=$Raccount server=$smtpserv \\\nport=587 user=$Eaccount password=$pass start-tls=yes file=$backupfile \\\nsubject=(\"$sysname Full Backup (\" . [\/system clock get date] . \")\") \\\nbody=(\"$sysname full Backup file see in attachment.\\nRouterOS version: \\\n$sysver\\nTime and Date stamp: \" . [\/system clock get time] . \" \" . \\\n[\/system clock get date]);\n:delay 5;\n:local exportfile (\"$sysname-backup-\" . \\\n[:pick [\/system clock get date] 7 11] . [:pick [\/system \\\nclock get date] 0 3] . [:pick [\/system clock get date] 4 6] . \".rsc\");\n:log info \"Creating new Setup Script file...\";\n\/export verbose file=$exportfile;\n:delay 2;\n:log info \"Sending Setup Script file via E-mail...\";\n\/tool e-mail send from=\"&lt;$Eaccount>\" to=$Raccount server=$smtpserv \\\nport=587 user=$Eaccount password=$pass start-tls=yes file=$exportfile \\\nsubject=(\"$sysname Setup Script Backup (\" . [\/system clock get date] . \\\n\")\") body=(\"$sysname Setup Script file see in attachment.\\nRouterOS \\\nversion: $sysver\\nTime and Date stamp: \" . [\/system clock get time] . \" \\\n\" . [\/system clock get date]);\n:delay 5;\n:log info \"All System Backups emailed successfully.\\nBackuping completed.\";<\/strong><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.4-1024x555.jpg\" alt=\"\" class=\"wp-image-401\" srcset=\"https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.4-1024x555.jpg 1024w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.4-300x163.jpg 300w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.4-768x416.jpg 768w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.4-1536x832.jpg 1536w, https:\/\/sznetwork.systems\/wp-content\/uploads\/2021\/12\/screenshot.4.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Add this script to Schedule to frequently run script<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Script for Mikrotik to send frequently backup files to email Winbox already is connected. First we go to the section System, Scripts Press ADD, new script. Fill name of script.. <a class=\"read-more-link\" href=\"https:\/\/sznetwork.systems\/?p=396\">read more&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[37],"tags":[47,33,35,31,32],"class_list":["post-396","post","type-post","status-publish","format-standard","hentry","category-mikrotik","tag-backup","tag-email","tag-how-to","tag-mikrotik","tag-script"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/posts\/396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=396"}],"version-history":[{"count":8,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/posts\/396\/revisions"}],"predecessor-version":[{"id":1897,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/posts\/396\/revisions\/1897"}],"wp:attachment":[{"href":"https:\/\/sznetwork.systems\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}