Page 1 of 1

Automatic backup script

Posted: Tue Mar 20, 2012 11:56 am
by beatblam
Guys am trying to set this automatic backup script in my all routers running OS 4.17, but when I run the script it gives me a error msg attached to this log file here, someone please help me what is wrong with the script below, how do I work it out...Your assistance will be highly appreciated....Thanks

SCRIPT!!!!!!!!!

/system script add name=backup source={/export file=([/system identity get name] . "-" . \
[:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6]); \
/tool e-mail send to=backups@domain.com subject=([/system identity get name] . " Backup " . \
[/system clock get date]) file=([/system identity get name] . "-" . [:pick [/system clock get date] 7 11] . \
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".rsc"); :delay 10; \
/file rem [/file find name=([/system identity get name] . "-" . [:pick [/system clock get date] 7 11] . \
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".rsc")]; \
:log info ("System Backup emailed at " . [/sys cl get time] . " " . [/sys cl get date])}
{
:global namE;
:set namE ("<".[/sys identity get name]."@domain.com>");
/tool e-mail set server=192.168.0.2 from=$namE;
:put $namE;
}
/system scheduler
add name="sched_backup" on-event="backup" start-date=jan/01/1970 start-time=07:30:00 interval=7d \
comment="" disabled=no

Re: Automatic backup script

Posted: Tue Mar 20, 2012 12:30 pm
by dominicbatty
I'd start by simply replacing the "from=$namE" with "from=<a known address>" to see if it's a function call or variable issue. You could also try a ":log info $namE;" right before the call to see what is actually in the $namE variable in case you have something wrong there.

I also think in my scripts that the external "<" and ">" in the from address are not required.

Cheers, Dominic.

Re: Automatic backup script

Posted: Tue Mar 20, 2012 8:09 pm
by beatblam
Thanks friend I include ":log info $namE;" and in the log it told me the from address was having space in between and after changing it its no longer bringing the error in log....

Thank you so much....if you can share the script that's working for you that will be great too....http://forum.mikrotik.com/posting.php?m ... =9&t=60389#

Re: Automatic backup script

Posted: Wed Mar 21, 2012 12:57 am
by dominicbatty
no worries. TBH I use email in most of my scripts for failover monitoring and other such stuff ... glad you are sorted. Dominic.

Re: Automatic backup script

Posted: Sun Jul 22, 2012 3:53 pm
by tamilmaran
Guys am trying to set this automatic backup script in my all routers running OS 4.17, but when I run the script it gives me a error msg attached to this log file here, someone please help me what is wrong with the script below, how do I work it out...Your assistance will be highly appreciated....Thanks

SCRIPT!!!!!!!!!

/system script add name=backup source={/export file=([/system identity get name] . "-" . \
[:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6]); \
/tool e-mail send to=backups@domain.com subject=([/system identity get name] . " Backup " . \
[/system clock get date]) file=([/system identity get name] . "-" . [:pick [/system clock get date] 7 11] . \
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".rsc"); :delay 10; \
/file rem [/file find name=([/system identity get name] . "-" . [:pick [/system clock get date] 7 11] . \
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".rsc")]; \
:log info ("System Backup emailed at " . [/sys cl get time] . " " . [/sys cl get date])}
{
:global namE;
:set namE ("<".[/sys identity get name]."@domain.com>");
/tool e-mail set server=192.168.0.2 from=$namE;
:put $namE;
}
/system scheduler
add name="sched_backup" on-event="backup" start-date=jan/01/1970 start-time=07:30:00 interval=7d \
comment="" disabled=no
just add the follwing , when you send emails
tls=on
it is required in new ver. ROS

Re: Automatic backup script

Posted: Mon Sep 24, 2012 2:49 am
by machack
Hello tamilmaran

Iam copy and mod script and make my script to make backup and export all RB configurations
: local mailserver [:resolve mail.domain.com.ar];

:log info "Starting Backup Script..."
:global backupfileA ([/system identity get name] . ".backup")
:global backupfileB ([/system identity get name] . ".script")
:global efrom ([/system identity get name] . "@domain.com.ar")
:if ([/file find name=$backupfileA] != "") do={/file rem $backupfileA};
:if ([/file find name=$backupfileB] != "") do={/file rem $backupfileB};
:delay 2s
/system backup save name=$backupfileA;
/system export file=$backupfileB;
:log info "Waiting 5s for backup to complete..."
:delay 5s
:log info "Backup being emailed..."
/tool e-mail send body=Backup1/2 subject=([/system identity get name] . " Backup1/2") to=dest-email@domain.com.ar from=email@domain.com.ar file=$backupfileA server=$mailserver password=PASSWORD user=email@domain.com.ar
/tool e-mail send body=Backup2/2 subject=([/system identity get name] . " Backup2/2") to=dest-email@domain.com.ar from=email@domain.com.ar file=$backupfileB server=$mailserver password=PASSWORD user=email@domain.com.ar
:log info "Waiting 5s for send-email complete..."
:delay 5s
:log info "Finished Backup Script!"

Please replace email@domain.com.ar and PASSWORD for SMTP auth and dest-email@domain.com.ar for dest address/.


Sorry for my bad Bad English