Page 1 of 1

Download files from RouterOS via http/https with curl/wget/browser

Posted: Mon Nov 11, 2024 8:35 pm
by giox969
Hello,
I'm developing my backup script (to be run in a Linux PC, not for Mikrotik RouterOS). I'm able to create a .backup file via the /rest API, but I cannot find a way to download it to my PC.

To create a backup I use:
POST /rest/system/backup/save
BODY: {"name": "myfilename.backup"}
and it works

Then I can see the full list of file with:
GET /rest/file?type=backup
from the above list I can have the ".id" field for each file.

The problem now is: how do I download the file I created ?
I have found that
POST /file/get
HEADER {'Content-Type': 'application/json'}
BODY { ".id": "*id_of_myfilename.backup", ".proplist": "contents" }
returns a JSON object with the file contents mixed with other strings and with encoding errors :(

Is there another way to access myfilename.backup and download it with an http GET request ?
Thank you

Re: Download files from RouterOS via http/https with curl/wget/browser

Posted: Mon Nov 11, 2024 10:43 pm
by rextended
Short:
Enable ftp and download from it
AND/OR
Send the file by internal fetch or mail.

Re: Download files from RouterOS via http/https with curl/wget/browser

Posted: Tue Nov 12, 2024 11:43 am
by giox969
Thank you for the hint.

FTP is disabled by default, but scp works by default without problems:
scp admin@routerip:/filename.backup .
Thank you again.