Community discussions

MikroTik App
 
xitriyded
just joined
Topic Author
Posts: 3
Joined: Fri Sep 29, 2023 12:49 pm

MikroTik Script to restore backup in scheduler

Sat Oct 07, 2023 11:13 am

Hi!
I'm trying to create a script to restore backup. My script is very simple, but it's not working from scheduler
:local backupfile "MikroTik_2011UiAS_408-20231006-0923.backup" 
/system backup load name=$backupfile

Any suggestions on how to restore backup from *.backup file?
 
xitriyded
just joined
Topic Author
Posts: 3
Joined: Fri Sep 29, 2023 12:49 pm

Re: MikroTik Script to restore backup in scheduler  [SOLVED]

Sat Oct 07, 2023 11:52 am

Found solution
Script
:local backupfile "MikroTik_2011UiAS_408-20231006-0923.backup"
/system backup load name=$backupfile password=""
/y
In Scheduler, in On Event: just type script's name.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: MikroTik Script to restore backup in scheduler

Thu Oct 12, 2023 10:50 am

/y at the end is wrong and useless.
 
xitriyded
just joined
Topic Author
Posts: 3
Joined: Fri Sep 29, 2023 12:49 pm

Re: MikroTik Script to restore backup in scheduler

Thu Feb 15, 2024 1:19 pm

/y at the end is wrong and useless.
Not working without it though
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: MikroTik Script to restore backup in scheduler

Thu Feb 15, 2024 1:26 pm

/y at the end is wrong and useless.
Not working without it though
Still wrong, becayse "/" before the y is useless, and is still useless inside the scheduler.

"y" only can be used just if the script is tested on terminal.

It's like this and there's nothing you can do about it.
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: MikroTik Script to restore backup in scheduler

Thu Feb 15, 2024 2:39 pm

Ok, I have to ask.

Why is a static value assigned to a variable?

I.e., wouldn't this be the same?
/system backup load name="MikroTik_2011UiAS_408-20231006-0923.backup" password=""
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: MikroTik Script to restore backup in scheduler

Thu Feb 15, 2024 9:48 pm

In this case, it is of no use,
otherwise if you have to do multiple operations on the same file
it is simpler to write a script using a variable/constant that represents the name of the file,
without rewriting it entirely each time.
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: MikroTik Script to restore backup in scheduler

Fri Feb 16, 2024 10:52 am

Yep, thanks :) , I suspected as much.

In a more sophisticated script it would make sense, but here it doesn't, if the script is automated and executed periodically one would use a variable for the file name to be able to "compose" it with the date taken from system time, i.e. something *like* this one:
viewtopic.php?p=960070#p1024637
 
User avatar
miku
just joined
Posts: 15
Joined: Fri Feb 23, 2024 3:57 pm
Location: Poland

Re: MikroTik Script to restore backup in scheduler

Sat Mar 23, 2024 11:36 pm

Hi,
This thread helped me a lot. I had to do a backup restore on a remote MT via REST API. I tried various parameters for a long time, but password="" was simply missing.

Thank You...

Who is online

Users browsing this forum: malks and 7 guests