Community discussions

 
beatblam
just joined
Topic Author
Posts: 8
Joined: Mon May 04, 2009 12:59 pm

Automatic backup script

Tue Mar 20, 2012 11:56 am

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
You do not have the required permissions to view the files attached to this post.
 
dominicbatty
Frequent Visitor
Frequent Visitor
Posts: 91
Joined: Wed Jul 07, 2010 12:26 pm

Re: Automatic backup script

Tue Mar 20, 2012 12:30 pm

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.
 
beatblam
just joined
Topic Author
Posts: 8
Joined: Mon May 04, 2009 12:59 pm

Re: Automatic backup script

Tue Mar 20, 2012 8:09 pm

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#
 
dominicbatty
Frequent Visitor
Frequent Visitor
Posts: 91
Joined: Wed Jul 07, 2010 12:26 pm

Re: Automatic backup script

Wed Mar 21, 2012 12:57 am

no worries. TBH I use email in most of my scripts for failover monitoring and other such stuff ... glad you are sorted. Dominic.
 
tamilmaran
Frequent Visitor
Frequent Visitor
Posts: 75
Joined: Mon Sep 05, 2011 9:36 pm

Re: Automatic backup script

Sun Jul 22, 2012 3:53 pm

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
If u like my post , then Hit the Karma! Thanks.
-
Thamizh Maran
RF Engineer
ZERONE Tech
India
 
User avatar
machack
newbie
Posts: 47
Joined: Fri Jun 01, 2007 9:35 pm
Location: San Luis Argentina
Contact:

Re: Automatic backup script

Mon Sep 24, 2012 2:49 am

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
Cesar Javier Robles
www.WindNet.com.ar
MTCNA - MTCTCE - MTCRE - MTCWE

Who is online

Users browsing this forum: No registered users and 14 guests