Community discussions

MikroTik App
 
aguenther
just joined
Topic Author
Posts: 1
Joined: Tue Jan 14, 2025 4:10 pm

Copy files from the MikroTik router via SMB

Tue Jan 14, 2025 4:15 pm

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
 
ConnyMercier
Forum Veteran
Forum Veteran
Posts: 777
Joined: Tue Dec 17, 2019 1:08 pm

Re: Copy files from the MikroTik router via SMB

Thu Jan 16, 2025 5:38 pm

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.
 
ConradPino
Member
Member
Posts: 455
Joined: Sat Jan 21, 2023 12:44 pm
Location: San Francisco Bay
Contact:

Re: Copy files from the MikroTik router via SMB

Thu Jan 16, 2025 7:20 pm

Add ROSE-storage package and reboot then create SMB disk:
/disk add type=smb ...
 
User avatar
grusu
Member Candidate
Member Candidate
Posts: 143
Joined: Tue Aug 13, 2013 7:35 am
Location: Bucharest, Romania

Re: Copy files from the MikroTik router via SMB

Thu Jan 16, 2025 8:14 pm

You don't need rose package.
 
ConradPino
Member
Member
Posts: 455
Joined: Sat Jan 21, 2023 12:44 pm
Location: San Francisco Bay
Contact:

Re: Copy files from the MikroTik router via SMB

Thu Jan 16, 2025 8:43 pm

You don't need rose package.
Agrees; my bad.
 
teslasystems
Frequent Visitor
Frequent Visitor
Posts: 62
Joined: Sun Aug 09, 2015 3:00 pm

Re: Copy files from the MikroTik router via SMB

Fri Jan 31, 2025 6:49 am

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.
 
User avatar
grusu
Member Candidate
Member Candidate
Posts: 143
Joined: Tue Aug 13, 2013 7:35 am
Location: Bucharest, Romania

Re: Copy files from the MikroTik router via SMB

Fri Jan 31, 2025 9:02 am

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.
 
teslasystems
Frequent Visitor
Frequent Visitor
Posts: 62
Joined: Sun Aug 09, 2015 3:00 pm

Re: Copy files from the MikroTik router via SMB

Sat Feb 01, 2025 2:10 pm

Looks like no one is even reading what he asked about...
 
optio
Forum Guru
Forum Guru
Posts: 1031
Joined: Mon Dec 26, 2022 2:57 pm

Re: Copy files from the MikroTik router via SMB

Sat Feb 01, 2025 6:38 pm

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.
Last edited by optio on Sat Feb 01, 2025 8:09 pm, edited 3 times in total.
 
optio
Forum Guru
Forum Guru
Posts: 1031
Joined: Mon Dec 26, 2022 2:57 pm

Re: Copy files from the MikroTik router via SMB

Sat Feb 01, 2025 8:02 pm

<delete>