#定义全局变量 :local from "root@ros9.com" :local user "root" :local password "123456" :local to "962000293@qq.com" :local cc "部门其他同事邮箱" :local address "smtp.email.qq.com" #上面是gmail的IP :local port "25" :local router "MikroTik-DT.OPS.RouteOS" #ROS 系统备份 /system backup save name=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6]); #导出所有配置 /export file=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6]); #备份用户数据库 /tool user dat save name=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".umb.backup"); #延迟1秒,目的是文件已经备份好了,然后再执行下面的步骤,否则下面的步骤发现没有备份文件时报错,从而导致你的脚本失效 :delay 2; #把系统备份发送到邮箱 /tool e-mail send server=($address) port=($port) cc=($cc) from=($from) user=($user) password=($password) to=($to) start-tls=yes subject=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".backup") file=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".backup") body=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".backup"); #把配置文档发送到邮箱 /tool e-mail send server=($address) port=($port) cc=($cc) from=($from) user=($user) password=($password) to=($to) start-tls=yes subject=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".rsc") file=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".rsc") body=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".rsc"); #把用户数据库文档发送到邮箱(Exchange好像不支持接收.umb,所以这里强制后缀为.umb.backup) /tool e-mail send server=($address) port=($port) cc=($cc) from=($from) user=($user) password=($password) to=($to) start-tls=yes subject=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".umb.backup") file=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".umb.backup") body=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".umb.backup"); #再次延迟20秒,目的是让上面的步骤即确保备份的文件都发送出去了再执行下面的删除操作 :delay 20; #删除刚才备份到ROS本地的文件(如果你空间足够、脚本执行每月/年才执行一次,你可以删除下面这三段脚本) /file remove ($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".backup"); /file remove ($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".rsc"); /file remove ($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".umb.backup");
RouteOS定时系统备份发送到邮箱
转载请注明出处:Ros资源网 » RouteOS定时系统备份发送到邮箱
相关推荐
-      RouterOS 定时重连 PPPoE 脚本
-      RouterOS搭建私有DDNS服务
-      ROS映射与回流原理分析
-      RouterOS脚本数组简单介绍及范例
-      RouterOS 软路由过滤指定网站域名
-      RouterOS VLAN Trunk和Access配置实例
-      关于CRS3xx系列L3/L4 Hardware-Offloading支持
-      RouterOS V7.1beta版本发布,又新增一重磅功能
评论前必须登录!
注册