What's new

Copy using CLI

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

utamav

Regular Contributor
Is it possible to copy and paste data between 2 drives connected to the USB 3.0 port and USB 2.0 port of the RT-AC68U using CLI?

The reason why I ask this is because if I want to transfer a huge amount of data from one drive to another connected to the router, it'll first download to my PC and then upload to the other drive which reduces the speed of transfer drastically. If I use the CLI transfer it should be faster because it's handled internally in the router, right?
 
SSH to the router (I'm assuming you already have or can find the guide on how to).

Once in enter the following 2 commands;
cd /mnt
ls

Will see a list of drives (sda1 and so one). These are the USB drives. List the contents of each with;
ls sda1

A simple copy command is;
cp sda1/filename sda2/

That would copy a file called 'filename' from the root of one USB drive to another.

If you want to copy large amounts of files and sub folders you can use the recursive option and wildcards;
cp -r sda1/somefolder/* sda2/someotherfolder

That would copy ALL of the contents of 'somefolder' including sub folders on the first USB to 'someotherfolder' on the other USB. Note that 'someotherfolder' must already exist.

I suggest you put a couple of USB pen drives on with some play files/folders and test you understand the syntax before you try it on the real data.

Note that if this is a one time requirement it may just be easier to plug the 2 drives directly into your PC and drag/drop or copy/paste the files between the drives as then no down/uploading will occur, it will all be USB>USB. I'm assuming these drives are already attached to the router and you need to do this semi-regularly (or remotely) without the need to re-plug stuff between router and PC.


Sent from my iPhone using Tapatalk
 
The Syntax is: cp /tmp/mnt/drive2.0-name/folder/file (or jocker ? and *) /tmp/mnt/drive3.0-name/folder/

The command mount will give you the list of mounted drives with the mount paths /tmp/mnt/drive-name.

The full syntax of the copy command cp (and all other busybox commands) is described here.
 
Thanks all. I should have mentioned, I am familiar with the cp command. I just wasn't sure if the router will handle the file transfer internally or over the network.

Based on your comments, I can take it as the router will handle the cp command internally.

I wish this was only a one time thing. Basically I want to keep both the disks synced. So I'll come up with a right commands in a script and just keep running that manually every now and then.
 
Thanks all. I should have mentioned, I am familiar with the cp command. I just wasn't sure if the router will handle the file transfer internally or over the network.

Based on your comments, I can take it as the router will handle the cp command internally.

I wish this was only a one time thing. Basically I want to keep both the disks synced. So I'll come up with a right commands in a script and just keep running that manually every now and then.
Use cron (cru on the router) to run scheduled jobs.
 
In which case I'd also strongly recommend using rsync rather than cp. it's perfect for syncing data. If it gets interrupted it carries on where it left off etc.

I'd assume it's easy enough to install on the router with entware.


Sent from my iPhone using Tapatalk
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top