Community discussions

MikroTik App
 
dima1002
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Fri Jan 26, 2018 8:40 pm

Backup in a subfolder

Sat Oct 08, 2022 9:51 am

I would like my backup in a subfolder. However, because of the variable, an error always occurs. How can one solve it?

/system backup save name=/backup/$backupName
local name [/system identity get name];
:local date [/system clock get date];
:local day [ :pick $date 4 6 ]
:local month [ :pick $date 0 3 ]
:local backupName ($name."_".$day."-".$month."_log");
:put $backupName

/system backup save name=/backup/$backupName
 
dima1002
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Fri Jan 26, 2018 8:40 pm

Re: Backup in a subfolder

Sat Oct 08, 2022 4:08 pm

I was able to solve the Problem with.
/tool fetch https://127.0.0.1/ dst-path=backup/mikrotik
Thank you
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Backup in a subfolder

Sat Oct 08, 2022 11:05 pm

Can be a solution, but you are forced to leave http(s) service active or enable/disable for use that function.
(Obviously you can use external website and "solve" this "problem")

This is better, also contain corrections on coding...:
{
/system 
:local name  [identity get name]
:local date  [clock get date]
:local day   [:pick $date 4 6]
:local month [:pick $date 0 3]

:local folderName "/backup"
:local backupName "$folderName/$name_$day-$month_log"

:put $backupName

/ip smb shares
:local temp [get [find default=yes] directory]
set [find default=yes] directory=$folderName
set [find default=yes] directory=$temp

/system backup save name="$backupName"
}
Last edited by rextended on Sat Jan 14, 2023 11:51 pm, edited 1 time in total.
 
eldoncito2019
Member
Member
Posts: 332
Joined: Fri Jun 14, 2019 1:07 pm

Re: Backup in a subfolder

Mon Oct 10, 2022 6:23 pm

Guys,
I'm trying to save a "rsc" backup to a subfolder, and I can't do it, here's my script
{
:local name  "750GL(SERVER)"
:local fname "RB"
:local backupname "$fname$name"

/ip smb shares
   :local temp [get [find default=yes] directory]
   set [find default=yes] directory=$fname
   set [find default=yes] directory=$temp
   export compact file=$backupname
}
Thanks for the help friends.



EL DONCITO.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Backup in a subfolder

Mon Oct 10, 2022 6:25 pm

where are the /?

and about the ( and ) on name, I do not know if are allowed or not on filename (probably yes)...
 
eldoncito2019
Member
Member
Posts: 332
Joined: Fri Jun 14, 2019 1:07 pm

Re: Backup in a subfolder

Mon Oct 10, 2022 6:37 pm

Solved friend Rextended

{
:local name  "750GL(SERVER)"
:local fname "RB"
:local backupname "$fname/$name"

/ip smb shares
   :local temp [get [find default=yes] directory]
   set [find default=yes] directory=$fname
   set [find default=yes] directory=$temp
  
/export compact file=$backupname
}




EL DONCITO.

Who is online

Users browsing this forum: No registered users and 20 guests