Found the following script on the forum sometimes last year and have used for a while on a lot of routers.
However more and more routers refuse to run it, and maybe these problems started after moving to ROS 4 some while ago.
First I was missing the “Sensitive” policy setting, but even with this the script refuses to run, or appears to have run without any backup sent.
Anyone to shed some light on this?
/tool e-mail
set from=<router>@<mydomain> server=<My SMTP server>
/system scheduler
add interval=1d name=schedulebackup on-event=ebackup policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive start-date=oct/29/2010 start-time=00:00:00
/system script
add name=ebackup policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="/system backup save name=([/system ident\
ity get name] . \"-\" . \\\r\
\n[:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6]); \\\r\
\n/tool e-mail send to=\"backup@<mydomain>\" subject=([/system identity get name] . \" Backup \" . \\\r\
\n[/system clock get date]) file=([/system identity get name] . \"-\" . [:pick [/system clock get date] 7 11] . \\\r\
\n[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . \".backup\"); :delay 10; \\\r\
\n/file rem [/file find name=([/system identity get name] . \"-\" . [:pick [/system clock get date] 7 11] . \\\r\
\n[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . \".backup\")]; \\\r\
\n:log info (\"System Backup emailed at \" . [/sys cl get time] . \" \" . [/sys cl get date])"
I don’t see a delay in the script between creating the file and trying to email it. Perhaps the file has not been completely saved and the email send fails. The time it takes to save the file could depend on hardware type and number of configuration entries.