I need i little help here
When the script runs and creates a backup on my router i need it generate the name as the Router ID + the date + the time.
How do i go about this
I need i little help here
When the script runs and creates a backup on my router i need it generate the name as the Router ID + the date + the time.
How do i go about this
like this?
{
local id [sys identity get name]
local date [sys clock get date ]
local time [sys clock get time]
sys backup save name=“$id;$date;$time”
}
Ah thanks. I’ve been trying to figure out how to bind the variables together
Is there anyway to get this working. I think the problem is the special characters that come along with the date and time
:log info “Starting Backup”
:local id [/system identity get name]
:local time [/system clock get time]
:local date [/system clock get date]
:local file “$id$date$time”
/export compact file=$file
:log info “Pausing for 20s”
:delay 20s
:log info “Sending Backup File via Email”
/tool e-mail send file=$file to=“email@domain.co.za” subject=([/system identity get name] .
" Backup") from=email@domain.co.za:log info “Backup Complete”
:log info “Pausing for 1m”
:delay 1m
file remove $file
:log info “Cleanup complete”
:log info ([/system identity get name] . \ " Backup Completed")
I do reply to this old post, since it may help other.
Problem is that file name can not contain /
So to get it to work, this character has to be removed or replaced to some like this
{
:local id [/system identity get name]
:local time [/system clock get time]
:local date [/system clock get date]
:local file "$id_$date_$time"
:local name
:for i from=0 to=([:len $file] - 1) do={
:local char [:pick $file $i]
:if ($char = "/") do={
:set $char "-"
}
:set name ($name . $char)
}
/export compact file=$name
}
If you also want to save the files so that they are easily sortable, add this 3 lines…
(And also you must be sure than the name of the routerboard do not containing special characters, not only like “/”)
{
:local id [/system identity get name]
:local time [/system clock get time]
:local date [/system clock get date]
# rex start
:local arrMonths {jan="01";feb="02";mar="03";apr="04";may="05";jun="06";jul="07";aug="08";sep="09";oct="10";nov="11";dec="12"}
:local today [/system clock get date]
:local date "$[:pick $date 7 11]-$($arrMonths->[:pick $date 0 3])-$[:pick $date 4 6]"
# rex end
:local file "$id_$date_$time"
:local name
:for i from=0 to=([:len $file] - 1) do={
:local char [:pick $file $i]
:if ($char = "/") do={
:set $char "-"
}
:set name "$name$char"
}
/export compact file=$name
}
This way is better, more readable ![]()
I was looking for how to compare two files if possible, and only take new backup and send it if different from previous backup.
checksum if possible or size.
I make backup and .rsc, but I compare only the .rsc (ignoring first date line) for see if are present some differencies
Are you doing that on the router it self?
Maybe!..
Technically it is possible, ![]()
but I do it on an external server where I upload the files.