 Keithb
join:2003-09-16 US
3 edits | MT backup script
Rhaas posted a snippet of code to automate backups quite a while ago in my thread. I've tried this manually and get an error. Below is my line:
/tool e-mail send to=<me@mydomain.net> subject=([/sy stem identity get name] . " Backup") from=[/system identity get name] file=([/s ystem identity get name] . ".backup") server=<mail.mydomain.net> changing me@mydomain.net and mail.mydomain.net to our domain name of course.
When running that, I get:
invalid value for argument server
Any ideas of what I'm doing wrong?
Also, when setting up the schedule, how do you actually set that up? In the scheduler, it asks for name, start time, start date, interval, and 'On Event'. Some are obvious, but the on event is losing me. Am I in the right place? |
|
  John Galt Forward, March Premium join:2004-09-30 Happy Camp | Extra space before the word Backup...? -- A is A |
|
 Keithb
join:2003-09-16 US | Hey John, thanks for the reply. That still didn't work. It seems like it may not like my mailserver possibly? Rhaas said IP in his post, but I figured DNS would take over? |
|
  John Galt Forward, March Premium join:2004-09-30 Happy Camp
·CenturyLink
| Well, ya got me. I am just starting down the long and torturous road that is Mikrotik.

 -- A is A |
|
 Keithb
join:2003-09-16 US | haha, I've been running it for a year, and I'm not even sure I'm on the road yet. lol |
|
  Rhaas Premium join:2005-12-19 Bernie, MO | I've always used the IP. I just tried with the fqdn and got the same error as you got. |
|
 Keithb
join:2003-09-16 US
| I try it with my IP and I still get the same error, strange. Man, this sucks.
I'm currently on 2.9.23. I wonder if I should upgrade?
I've had issues with assigning IP's to PPPOE secrets and when removing them they re-appear, it doesn't actually remove it. |
|
 Believer
join:2002-07-04 Baltimore, MD | First, use quotes around the server name and e-mail address.
Second, just setup the server under /tool e-mail and then you won't have to set it. -- Comtrain Certified Tower Climber |
|
 Keithb
join:2003-09-16 US | Do you happen to know the command to set the server? |
|
 Believer
join:2002-07-04 Baltimore, MD | /tool e-mail set server="XXX.XXX.XXX.XXX" /tool e-mail set from="sender@domain.com" -- Comtrain Certified Tower Climber |
|
 jdmarti1 Jack
join:2004-06-15 Oilton, OK
| Here is my script and schedule - this does a backup, and works daily. I also have one the does an export and mails it to me. Same thing, just a text file. I have also included the scheduler portion - this automates it all.
/ system script add name="ebackup" source="/system backup save 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\]\); /tool e-mail send to=\"admin@mydomain.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\] . \".backup\"\); :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\] . \".backup\"\)\]; :log \ info \(\"System Backup emailed at \" . \[/sys cl get time\] . \" \" . \ \[/sys cl get date\]\)" \ policy=ftp,reboot,read,write,policy,test,winbox,password
/ system scheduler add name="email-backup" on-event=ebackup start-date=jan/01/1970 \ start-time=06:05:00 interval=1d comment="" disabled=no -- »magicwisp.com |
|
 Keithb
join:2003-09-16 US 1 edit | Thanks jdmart1, that worked just as I needed. Thanks again for the scheduler.
BTW, does that script over-write the file? Or create a new one each day? It seems like it would fill up my DOM card pretty fast. |
|
 jdmarti1 Jack
join:2004-06-15 Oilton, OK | It deletes the file when done. -- »magicwisp.com |
|
 eauxnguyen
join:2006-03-12 Alexandria, OH | reply to Keithb Hey Jack thanks for sharing that script. I have been trying to accomplish exactly what it does.
Owen |
|
 butchevans Premium join:2007-01-15 Malden, MO
| reply to Keithb »www.butchevans.com/readarticle.p···le_id=17
That is a complete script with explanations of how it works. Hope it's useful. -- Butch Evans »www.butchevans.com/ |
|
 jdmarti1 Jack
join:2004-06-15 Oilton, OK
| I also have one that runs that creates my config as a txt file. (Just like when you type export). The script is below:
/ system script add name="config-export" 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=\"admin@magicwisp.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\]\)" \ policy=ftp,reboot,read,write,policy,test,winbox,password
The scheduler for it:
/ system scheduler add name="export-email" on-event=config-export start-date=jan/01/1970 start-time=06:05:00 interval=1d \ comment="" disabled=no -- »magicwisp.com |
|
  seagreen Premium,Mod join:2001-05-14 out there | reply to Keithb Added to the FAQ as a link back to this thread: »Wireless ISP FAQ »Are there any Mikrotik backup scripts I can use? |
|
  John Galt Forward, March Premium join:2004-09-30 Happy Camp
·CenturyLink
| It would be great if other Mikrotik users also had some of their scripts posted in the FAQ section.
It would help Mikrotik nOOBS get their feet wet by having something to run, and also to dissect, examine and fool around with. -- A is A |
|