Community discussions

MikroTik App
 
Charli883
just joined
Topic Author
Posts: 1
Joined: Sat Oct 20, 2018 12:51 pm

MIkrotik backup script

Mon Nov 19, 2018 1:38 pm

I need your help, I am trying to create a backup file on mikrotik, but it always fail to create a backup can you help me please?
/system backup save name=([/system identity get name]"_"[/system clock get date]"log")
Format should be Hostname_MonthDaybackup.backup. For example Mikrotik_1205Log.backup

Can you help me please? Thank you.
 
User avatar
fmarais007
newbie
Posts: 26
Joined: Thu Jan 11, 2018 9:16 am

Re: MIkrotik backup script

Mon Nov 19, 2018 2:45 pm

I believe the issue is your
/system clock get date
If you look at the output through the "put" command, it will print something like "nov/19/2018"
Herein lies the issue as you can't have "/" in your name.
 
User avatar
karlisi
Member
Member
Posts: 440
Joined: Mon May 31, 2004 8:09 am
Location: Latvia

Re: MIkrotik backup script

Tue Nov 20, 2018 10:10 am

Something like this?
:local filename;
:local date [/system clock get date];
:local name [/system identity get name];

:local months ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
:local varMonth [:pick $date 0 3];
:set varMonth ([ :find $months $varMonth -1 ] + 1);
:if ($varMonth < 10) do={ :set varMonth ("0" . $varMonth); }

:local varDay [:pick $date 4 6];
:set filename ($name. "_" .$varMonth.$varDay);

/system backup save name=$filename;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: MIkrotik backup script

Tue Nov 20, 2018 10:28 am

I would have added Year :)
:local filename;
:local date [/system clock get date];
:local name [/system identity get name];

:local months ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
:local varMonth [:pick $date 0 3];
:set varMonth ([ :find $months $varMonth -1 ] + 1);
:if ($varMonth < 10) do={ :set varMonth ("0" . $varMonth); }

:local varDay [:pick $date 4 6];
:local varYear [:pick $date 7 11];
:set filename ($name. "_" .$varYear.$varMonth.$varDay);

/system backup save name=$filename;
 
User avatar
karlisi
Member
Member
Posts: 440
Joined: Mon May 31, 2004 8:09 am
Location: Latvia

Re: MIkrotik backup script

Tue Nov 20, 2018 2:00 pm

I would have added Year :)
It wasn't in OP requirements ;)

Who is online

Users browsing this forum: Bing [Bot], marsando, xrlls and 115 guests