Trouble with backup script

Hi all,

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])"

You might want to try a couple things. First I enable e-mail logging.

/system logging
add topics=e-mail action=memory

Then try a test email and check the log.

/tool e-mail
send to="backup@mydomain.com" subject="email test" body="email test"

Does that work?

This works for me, However …
This script create backup file each time, but send and remove backup file only each second time.
Anybody knows why?

P.S
Does anybody have example how to move backup file to ftp server?

It’ looks like some kind of bug for me because:

I have tried to use example from http://wiki.mikrotik.com/wiki/Send_Backup_email
So ,
I’ve change “backup to rsc” and
source={/system backup save name=
to
source={/export file=

In this case script works perfectly (each time)!!!

Anyone?

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.