Community discussions

MikroTik App
 
markwien
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 69
Joined: Sun Jul 22, 2018 10:49 am

/tool fetch url doest work

Wed Jul 28, 2021 1:34 pm

Hi i try to fetch all files in /file and copy them to a other mikrotik.
When i use the tool in command line it works fine, but inside the script it doesnt. Can someone tell me how to write it correct?

/tool fetch url=sftp://XXXXXX/test.txt upload=yes user=backupuser password=XXXXXXsrc-path=test.txt src-address=XXXXX
:foreach a in=[/file find] do={
    /tool fetch url=("sftp://XXXXXXX/" .$a) upload=yes user=backupuser password=ashahahha src-path=$a src-address=92.XXXXXXX;
    }
}


thx

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

Re: /tool fetch url doest work

Wed Jul 28, 2021 1:55 pm

§

You forget to not send.... directories and disks...
Your remote sftp create directories when are not presents?
:local filelist ""
/file
:foreach file in=[find where type!=disk and type!=directory] do={
    /tool fetch url=("sftp://XXXXXXX/$file") upload=yes user=backupuser password=ashahahha src-path=$file src-address=92.x.x.x
}


For true backup you can adapt this, is by mail, but you can modify it to use fetch:
viewtopic.php?f=1&t=175360&p=858564#p858564

Who is online

Users browsing this forum: NxtGen [Bot] and 13 guests