What's new

Direct copy from N66U(USB) to NAS

  • 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!

huotg01

Senior Member
First of all, it was some kind of fresh air when I foud out about this version. Thanks to RMerlin.>
My situation: I have a USB drive hooked to the RT-N66U>I have also 2 NAS on my home network.>
My question: is it possible to setup something in order to automatically backup some content from the N66U to the NAS without using a 3rd party (my PC...)? All the boxes beeing on Linux and wired directly to the RT-N66U, it should exist a way to do it without taxing the Wi-Fi network and another intermediate Windows device ?>

Author: TeHashX Posted: 2/3/2013 5:03:00 PM
Yes you can, first load Merlin's firmware, enable jffs partition and create a script that mounts your NAS folder with CIFS and another script with CRON job to copy (backup) at schedule time desired files or folders to your NAS folder.
Post here a request (on this forum I receive notifications) and I will try to help you.

"...first load Merlin's firmware, enable jffs partition": these 2 points are done.

Thanks you for helping me to go further.

GH
 
First you have to mount your nas folder where to save files, should have write permission to do that.
# mkdir /mnt/sda1/nas (this will create a folder where nas will be mounted)
# mount -t cifs \\\\192.168.1.100\\nasfolder /mnt/sda1/nas -o "username=nas_username,password=nas_password"
Replace ip with your nas ip and input a username and password if required to access nas.
That is all for now, see if the folder is mounted and after we will make a script to automount and copy.
 
Thanks

Just tried. No error msg, but it seems than other that my Entware partition, there is nothing else mounted. Is there a log ?

By the way I just installed rsync (Entware), but maybe this is not part of the solution ? Anyway, you have an idea on how I can debug the "mount" ?

Thanks

GH
 
/tmp/syslog.log will contain more details if there was an error.

You can view the list of current mounts with the "mount" command.
 
I mounted my windows "Share" folder to /tmp/mnt/sda1/share and this is the mount output:

admin@RT-AC66U:/tmp/mnt# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
proc on /proc type proc (rw)
tmpfs on /tmp type tmpfs (rw)
devfs on /dev type tmpfs (rw,noatime)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
/dev/mtdblock5 on /jffs type jffs2 (rw,noatime)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /tmp/mnt/sda1 type ext3 (rw,nodev,noatime,data=ordered)
\134\134192.168.1.100\134Share on /tmp/mnt/sda1/share type cifs (rw,mand,unc=\\192.168.1.100\Share,username=thx,uid=0,gid=0,rsize=16384,wsize=57344)


You have to set read/write permission on nas folder first
# chmod 777 /mnt/sda1/nas

Post here your "mount" output
 
I mounted my windows "Share" folder to /tmp/mnt/sda1/share and this is the mount output:
...
Post here your "mount" output

rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
proc on /proc type proc (rw)
tmpfs on /tmp type tmpfs (rw)
devfs on /dev type tmpfs (rw,noatime)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
/dev/mtdblock4 on /jffs type jffs2 (rw,noatime)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /tmp/mnt/ENTWARE type ext2 (rw,nodev,noatime)


GH
 
Your usb device has the label ENTWARE, just need the replace sda1
# mkdir /mnt/ENTWARE/nas
# chmod 777 /mnt//ENTWARE/nas
# mount -t cifs \\\\192.168.1.100\\nasfolder /mnt/ENTWARE/nas -o "username=nas_username,password=nas_password"
 
Last edited:
...getting better:
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
proc on /proc type proc (rw)
tmpfs on /tmp type tmpfs (rw)
devfs on /dev type tmpfs (rw,noatime)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
/dev/mtdblock4 on /jffs type jffs2 (rw,noatime)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /tmp/mnt/ENTWARE type ext2 (rw,nodev,noatime)
\134\134192.168.1.180\134Temp on /tmp/mnt/ENTWARE/nas type cifs (rw,mand,unc=\\192.168.1.180\Temp,username=huogas,uid=0,gid=0,rsize=16384,wsize=57344)

I decided to learn using a share on my laptop...Will have a fight with the NAS later;-)

For the moment, let's go with the share on the laptop...

GH
 
...the fight is over with the NAS :)
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
proc on /proc type proc (rw)
tmpfs on /tmp type tmpfs (rw)
devfs on /dev type tmpfs (rw,noatime)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
/dev/mtdblock4 on /jffs type jffs2 (rw,noatime)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /tmp/mnt/ENTWARE type ext2 (rw,nodev,noatime)
\134\134192.168.1.51\134huogas on /tmp/mnt/ENTWARE/nas type cifs (rw,mand,unc=\\192.168.1.51\huogas,username=huogas,uid=0,gid=0,rsize=16384,wsize=57344)

Thanks. What would be the next step ?

GH
 
So, you need to copy a file or a folder from usb drive to your nas?
First we need to make a test
# cp /mnt/ENTWARE/usbfolder/filename /mnt/ENTWARE/nas/
or to copy entire folder
# cp -r /mnt/ENTWARE/usbfolder /mnt/ENTWARE/nas/
If is ok, we just need to create a script and a cron job to automatically schedule the transfer.
Just give more detail what kind of files you want to copy
 
Last edited:
And don't forget rsync - invaluable if your ultimate goal is to push backups of a folder to a share. :)
 
So, you need to copy a file or a folder from usb drive to your nas?
First we need to make a test
...
If is ok, we just need to create a script and a cron job to automatically schedule the transfer.
Just give more detail what kind of files you want to copy
The copy works well.
And don't forget rsync - invaluable if your ultimate goal is to push backups of a folder to a share. :)
Good point. The goal is to backup weekly a folder on the router usb disk to a share on the NAS.

Thanks,

GH
 
I never used rsync, I have to read about it.
The following script will mount and copy your nas folder
echo "#!/bin/sh" > /jffs/scripts/backup-usbtonas.sh
echo "mount -t cifs \\\\\\\\192.168.1.100\\\\nasfolder /mnt/ENTWARE/nas -o \"username=nas_username,password=nas_password\"" >> /jffs/scripts/backup-usbtonas.sh
echo "sleep 10" >> /jffs/scripts/backup-usbtonas.sh
echo "cp -r /mnt/ENTWARE/usb_folder_to_backup /mnt/ENTWARE/nas/" >> /jffs/scripts/backup-usbtonas.sh
chmod a+rx /jffs/scripts/backup-usbtonas.sh
This script will schedule a cron job to run every saturday at 03:00 AM (if you want to change time, have a look here)
echo "#!/bin/sh" > /jffs/scripts/init-start
echo "cru a BackupUsbToNas \"0 3 * * 6 /jffs/scripts/backup-usbtonas.sh\"" >> /jffs/scripts/init-start
chmod a+rx /jffs/scripts/init-start
It seams a little bit complicated until I figure out how rsync works but don't forget to change the values in red and do a test with this command:
# /jffs/scripts/backup-usbtonas.sh
 
The following script will mount and sync your nas folder with rsync
First remove previous scripts
rm jffs/scripts/backup-usbtonas.sh
rm jffs/scripts/init-start
mkdir /mnt/ENTWARE/nas
chmod 777 /mnt/ENTWARE/nas
Install rsync
opkg install rsync
Mount and Sync script
echo "#!/bin/sh" > /jffs/scripts/sync-usbtonas.sh
echo "mount -t cifs \\\\\\\\192.168.1.100\\\\nasfolder /mnt/ENTWARE/nas -o \"username=nas_username,password=nas_password\"" >> /jffs/scripts/sync-usbtonas.sh
echo "sleep 10" >> /jffs/scripts/sync-usbtonas.sh
echo "rsync -r -v -u -s /mnt/ENTWARE/usb_folder_to_sync /mnt/ENTWARE/nas/" >> /jffs/scripts/sync-usbtonas.sh
chmod a+rx /jffs/scripts/sync-usbtonas.sh
This script will schedule a cron job to run every saturday at 03:00 AM (if you want to change time, use this cron job generator)
echo "#!/bin/sh" > /jffs/scripts/init-start
echo "cru a SyncUsbToNas \"0 3 * * 6 /jffs/scripts/sync-usbtonas.sh\"" >> /jffs/scripts/init-start
chmod a+rx /jffs/scripts/init-start
Like usual, change the values in red
Anyway, the only difference with this method is that rsync will copy only the new files in usbfolder and not all like with ''cp -r'' command, now depends on you what do you need.
Test with
rsync -r -v -u --progress -s /mnt/ENTWARE/usb_folder_to_sync /mnt/ENTWARE/nas/
 
Last edited:
Thanks TeHashX. What a job! :)
I will try that and come back here.

GH
 
Another good use of rsync is if you want to backup from linux to a usb drive connected to the N66U you can use the following command:

rsync -arv -e ssh --rsync-path=/tmp/mnt/sda1/asusware/bin/rsync /localpath admin@RT-N66U:/tmp/mnt/sda1/

you will of course need to install rsync using "ipkg install rsync" and have ssh running

For cron jobs use a public key or -p "password"
 
The following script will mount and sync your nas folder with rsync
First remove previous scripts

Install rsync

Mount and Sync script

This script will schedule a cron job to run every saturday at 03:00 AM (if you want to change time, use this cron job generator)


Like usual, change the values in red
Anyway, the only difference with this method is that rsync will copy only the new files in usbfolder and not all like with ''cp -r'' command, now depends on you what do you need.
Test with

I am trying to figure out a similar script for my rtn66u but to copy one attached usb drive to another on a daily basis. Both drives are ntfs formated for compatability reasons... I think I first need to make sure that the script first mounts my drives according to their uid's...basically I have two ysb enclosures with raid0 and I would like to mirror one to the other every night....any help with this will be greatly apreciated...
 

Sign Up For SNBForums Daily Digest

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