Community discussions

MikroTik App
 
ntrits
just joined
Topic Author
Posts: 5
Joined: Mon Sep 15, 2008 12:16 pm

Revert ROS changes after a time (in case lost your system comunication)

Wed Jun 10, 2015 6:32 pm

This can be a future in webfig or winbox

Add this script at any name (I'm using the name: Back2Time)
Copy and paste the following code

when run it it makes 3 changes.
a) make a backup file (bktime)
b) make a schedule to restore the above file (bksch)
c) make a new script with a name like (!Startet at 18.25.51 and Revert after 10m - Run me to Finalize Changes)
(because of the ! at start the script is on top of the script list)

If you run the script the file bktime the schedule bksh and the script deleted
If wait for 10 min's the scheduler restore the bktime file and the router configuration revert 10 min's back

:local timetorevert "10m"
:local hourt [:pick [/system clock get time] 0 2]
:local mint [:pick [/system clock get time] 3 5]
:local sect [:pick [/system clock get time] 6 8]
:local timet "$hourt.$mint.$sect"
:if ([:len [/file find name=bktime.backup]] > 0) do={/file remove bktime.backup} 
:do { /system scheduler remove bksch;} on-error={ };

#:if ([:len [/system scheduler name=bksch]] > 0) do={/system scheduler remove bksch} 
:delay 2

/system backup save name=bktime dont-encrypt=yes password=123

/system scheduler add interval=$timetorevert name=bksch on-event="/system backup load name=bktime.backup password=123
/file remove bktime.backup
/system scheduler remove bksch"

/system script add name="!Startet at $timet and Revert after $timetorevert - Run me to Finalize Changes" source="/file remove bktime.backup
/system scheduler remove bksch
/system script remove \"!Startet at $timet and Revert after $timetorevert - Run me to Finalize Changes\"
"
Of course the 10 min's can change to any time!
 
patrick7
Member
Member
Posts: 353
Joined: Sat Jul 20, 2013 2:40 pm

Re: Revert ROS changes after a time (in case lost your system comunication)

Wed Jun 10, 2015 6:42 pm

Why not use safe mode?
 
ntrits
just joined
Topic Author
Posts: 5
Joined: Mon Sep 15, 2008 12:16 pm

Re: Revert ROS changes after a time (in case lost your system comunication)

Wed Jun 10, 2015 6:54 pm

because no undo time