Does anyone know of a script that will export the config and download it to specified folder on a Windows PC running Winbox?
I see the fetch command, but I don’t want to always run an ftp server on my PC.
Thanks!
Does anyone know of a script that will export the config and download it to specified folder on a Windows PC running Winbox?
I see the fetch command, but I don’t want to always run an ftp server on my PC.
Thanks!
Use your hand to drag and drop the file.
LOL!
My hand is busy (![]()
I’ve got this working:
tool fetch address=192.168.2.22 src-path=212hex-12-9-2022.rsc user=mikrotik mode=ftp passwo
rd=mikrotik dst-path=212hex-12-9-92022.rsc port=21 host="" upload=yes
But what I want is to be able to use wildcards, like:
tool fetch address=192.168.2.22 src-path=212hex*.rsc user=mikrotik mode=ftp passwo
rd=mikrotik dst-path=212hex*.rsc port=21 host="" upload=yes
But that fails. I tried it without including DST-PATH but that didn’t work either.
My goal is to have a script that exports the current config to a file named 212hex-.rsc
and then download to the PC.
jokes aside,
your OP do not say the same of your reply
Wait some moment and I write one script…
Wildcard used for what? All file to remote folder?
Wildcard are unsupported, and also is one error to have wildcard on destination, have not any sense.
And be smart and use yyyy-mm-dd on filename instead of the nonsense in computer science mm-dd-yyyy or dd-mm-yyyy…
You write one hundred and twenty-four: 124, 241 or 421?
# for v6
/export file=exportthis
# for v7
/export show-sensitive file=exportthis
/tool fetch upload=yes mode=ftp ascii=no src-path="/exportthis.rsc" dst-path="212hex-2022-12-13.rsc" \
address=192.168.2.22 port=21 user=mikrotik password=mikrotik
If you need to upload more than one file at time to a remote ftp folder the script is different.
That is great, thank you.
But, what would make it ever better is if the exported filename had today’s date (yyyy-mm-dd) appended, like:
212hex-2022-12-13
And that is why I wanted to upload using wildcards: That is, so that I could upload all *.rsc files.
That way, when I change configs and break it, I can choose what date’s config to restore.
Schedule it one time at day and you have backup for everyday…
:global nowdate do={
/system clock
:local vdate [get date]
:local yyyy [:pick $vdate 7 11]
:local M ([:find "xxanebarprayunulugepctovecANEBARPRAYUNULUGEPCTOVEC" [:pick $vdate 1 3] -1] / 2); :if ($M>12) do={:set M ($M - 12)}
:local MM [:pick "0$M" 1 3]
:local dd [:pick $vdate 4 6]
:return "$yyyy-$MM-$dd"
}
# for v6
/export file="exportthis-$[$nowdate]"
# for v7
/export show-sensitive file="exportthis-$[$nowdate]"
/tool fetch upload=yes mode=ftp ascii=no src-path="/exportthis-$[$nowdate].rsc" dst-path="/<PUT-THE-FOLDER-NAME-HERE-NOT-THE-FILENAME>" \
address=192.168.2.22 port=21 user=mikrotik password=mikrotik
Wow!
That is so great! I would never have been able to pull that date format into a variable.
The destination path alone doesn’t seem to be working:
dst-path=“/”
I confirmed the path exists:
/212hex
and it works if I specify the dst filename:
dst-path=“/212hex/hex.rsc”
(is not a variable, is a function: everytime is called, you obtain the current date)
(for this reason, do not run the script at 23:59 but from 00:00 onwards until 23:58, just to be safe)
/212hex with “/” (dst-path=“/212hex/”)?
this is not a fetch problem but accepted syntax from ftp server
dst-path="/212hex/exportthis-$[$nowdate].rsc"
I was referring to $nowdate
This works:
/tool fetch upload=yes mode=ftp ascii=no src-path="/212hex-$[$nowdate].rsc" dst-path="/212hex/212hex-$[$nowdate].rsc" address=192.168.2.22 port=21 user=mikrotik password=mikrotik
This does not work:
/tool fetch upload=yes mode=ftp ascii=no src-path="/212hex-$[$nowdate].rsc" dst-path="/212hex/" address=192.168.2.22 port=21 user=mikrotik password=mikrotik
Thank you!