Page 1 of 1

Copy files from the MikroTik router via SMB

Posted: Tue Jan 14, 2025 4:15 pm
by aguenther
There are many instructions on how to move automatic backups of the router via FTP to an external storage.

I would now like backups created by the router to be stored on an external storage device via SMB.

So far I have only found instructions on how to create an SMB share on the Mikrotik router, but I would like to copy/move local files from a Mikrotik router to an SMB share (Windows), is that possible?

Greetings
Andreas

Re: Copy files from the MikroTik router via SMB

Posted: Thu Jan 16, 2025 5:38 pm
by ConnyMercier
Good Evening Andreas,

If i am not mistake, RouterOS doesn`t support SMB export out-of-the-box
Nevertheless, if you have a device with a arm, arm64, x86 or tile architecture,
you can install the ROSE-Package (https://help.mikrotik.com/docs/spaces/R ... SE-storage)
that support SMB-Share.

I just tested it with a RB4011, works great.

Re: Copy files from the MikroTik router via SMB

Posted: Thu Jan 16, 2025 7:20 pm
by ConradPino
Add ROSE-storage package and reboot then create SMB disk:
/disk add type=smb ...

Re: Copy files from the MikroTik router via SMB

Posted: Thu Jan 16, 2025 8:14 pm
by grusu
You don't need rose package.

Re: Copy files from the MikroTik router via SMB

Posted: Thu Jan 16, 2025 8:43 pm
by ConradPino
You don't need rose package.
Agrees; my bad.

Re: Copy files from the MikroTik router via SMB

Posted: Fri Jan 31, 2025 6:49 am
by teslasystems
Currently, there are no any commands to do that. But as far as I know, they are working on improving file management and hope this functionality will appear in the final 7.18 release or some beta.

Re: Copy files from the MikroTik router via SMB

Posted: Fri Jan 31, 2025 9:02 am
by grusu
Hi,

Try this:

https://help.mikrotik.com/docs/spaces/R ... nexample.4


disk add smb-address=10.155.145.11 smb-share=share1 smb-user=user smb-password=password type=smb

Work only from cli.

Re: Copy files from the MikroTik router via SMB

Posted: Sat Feb 01, 2025 2:10 pm
by teslasystems
Looks like no one is even reading what he asked about...

Re: Copy files from the MikroTik router via SMB

Posted: Sat Feb 01, 2025 6:38 pm
by optio
Yes, there is no copy/move file commands for CLI, only move over GUI can be done. For now only solution (without fetch command copy hack) is that backup script creates files directly on mounted disk path without need for copy/move.

To copy file locally over SSH using fetch command:
/tool/fetch url=sftp://127.0.0.1 user=<ROS_USER> upload=yes src-path=<copy_from_file_path> dst-path=<copy_to_file_path>
If you have password allowed SSH login password=<ROS_USER_PASSWORD> can be added to fetch command argument, but is not recommended, better to use key auth.

SSH local access setup
For key auth to work, private/public key pair needs to be exported into files:
/ip/ssh/export-host-key key-file-prefix=ssh_key
and imported for SSH ROS user which will be used in fetch command:
/user/ssh-keys/import public-key-file=ssh_key_<ssh_alg>_pub.pem user=<ROS_USER> key-owner=local
/user/ssh-keys/private/import private-key-file=ssh_key_<ssh_alg>.pem user=<ROS_USER> key-owner=local
Depending on firewall rules, in my case I needed to accept loopback interface in input chain to be able to connect to local SSH:
/ip/firewall/filter add action=accept chain=input in-interface=lo
Also additional note: if there is IP restriction in /ip/service for ssh, then bridge address can be used instead 127.0.0.1 in sftp fetch url because localhost address cannot be added there.

In this case if file moving is needed, then file can be just deleted by /file/remove <copy_from_file_path> after is successfully uploaded by fetch command.

Re: Copy files from the MikroTik router via SMB

Posted: Sat Feb 01, 2025 8:02 pm
by optio
<delete>