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?
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/ROS/pages/259031065/ROSE-storage)
that support SMB-Share.
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.
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:
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:
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.
My goal has been the same, automated backups on the device being copied elsewhere, but Iâve been treating the MikroTik as an SMB host with a Windows box as the client that executes the copy. I was struggling with this in 7.17, finding that while I could access the share the contents couldnât be copied out, and after upgrading to 7.18.2 today, this seems to have been solved. Not 100% sure it will apply the same for this scenario, where the MikroTik executes the copy to a remote host.
I would also note that from a security standpoint, I believe itâs better to have your backups retrieved from a device, rather than pushed from the device. That way the backup system doesnât need to grant any ingress access to remote devices.
So, based on the SMB function and what Iâve been taught is best practice, my method is:
Configure SMB on the Mikrotik, with appropriate directory share & permissions
Mount that share in a Win11 box
Use Task Scheduler to execute a batch that mirrors the contents of the mount to another location (I use FreeFileSync)
Relevant bits from the release notes:
7.18
*) smb - fixed connection issues with clients using older SMB versions (introduced in v7.17);
*) smb - fixes for SMB server;
*) smb - improved system stability;
There is a file move command: /file set name=
I donât know since which RoS version, in Ros 7.16.2 is there, in 6.32.3 is not.
It can also move files to/from/between smb shares added with /disk add type=smb âŚ
I donât know if this was intended this way, I mean to include move in a rename operation. In the background I guess is a copy + delete.
I couldnât find any file copy solution other than fetch.
Iâm looking forward to the improved file management.
For automated backup files suggest to use SCP and pull new created backup files from any host as you need.
Solution without user/password typing, need to add userâs keys first.
Check firewall rules allowing ssh connections and voile.