Direct copy from N66U(USB) to NAS

Discussion in 'Asuswrt-Merlin' started by huotg01, Feb 3, 2013.

  1. huotg01

    huotg01 Senior Member

    Joined:
    Feb 3, 2013
    Messages:
    420
    Location:
    Montreal
    "...first load Merlin's firmware, enable jffs partition": these 2 points are done.

    Thanks you for helping me to go further.

    GH
     
  2. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    759
    Location:
    Europe
    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.
     
  3. huotg01

    huotg01 Senior Member

    Joined:
    Feb 3, 2013
    Messages:
    420
    Location:
    Montreal
    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
     
  4. RMerlin

    RMerlin Part of the Furniture

    Joined:
    Apr 14, 2012
    Messages:
    13,005
    Location:
    Canada
    /tmp/syslog.log will contain more details if there was an error.

    You can view the list of current mounts with the "mount" command.
     
  5. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    759
    Location:
    Europe
    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
     
  6. huotg01

    huotg01 Senior Member

    Joined:
    Feb 3, 2013
    Messages:
    420
    Location:
    Montreal
    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
     
  7. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    759
    Location:
    Europe
    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: Feb 10, 2013
  8. huotg01

    huotg01 Senior Member

    Joined:
    Feb 3, 2013
    Messages:
    420
    Location:
    Montreal
    ...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
     
  9. huotg01

    huotg01 Senior Member

    Joined:
    Feb 3, 2013
    Messages:
    420
    Location:
    Montreal
    ...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
     
  10. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    759
    Location:
    Europe
    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: Feb 10, 2013
  11. RMerlin

    RMerlin Part of the Furniture

    Joined:
    Apr 14, 2012
    Messages:
    13,005
    Location:
    Canada
    And don't forget rsync - invaluable if your ultimate goal is to push backups of a folder to a share. :)
     
  12. huotg01

    huotg01 Senior Member

    Joined:
    Feb 3, 2013
    Messages:
    420
    Location:
    Montreal
    The copy works well.
    Good point. The goal is to backup weekly a folder on the router usb disk to a share on the NAS.

    Thanks,

    GH
     
  13. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    759
    Location:
    Europe
    Your nas is always on?
     
  14. huotg01

    huotg01 Senior Member

    Joined:
    Feb 3, 2013
    Messages:
    420
    Location:
    Montreal
    Yes.

    Envoyé depuis mon SGH-I717D avec Tapatalk
     
  15. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    759
    Location:
    Europe
    I never used rsync, I have to read about it.
    The following script will mount and copy your nas folder
    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)
    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
     
  16. huotg01

    huotg01 Senior Member

    Joined:
    Feb 3, 2013
    Messages:
    420
    Location:
    Montreal
  17. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    759
    Location:
    Europe
    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
     
    Last edited: Feb 18, 2013
  18. huotg01

    huotg01 Senior Member

    Joined:
    Feb 3, 2013
    Messages:
    420
    Location:
    Montreal
    Thanks TeHashX. What a job! :)
    I will try that and come back here.

    GH
     
  19. paulbarrett

    paulbarrett New Around Here

    Joined:
    Oct 28, 2012
    Messages:
    2
    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"
     
  20. brusyev

    brusyev Occasional Visitor

    Joined:
    Jul 17, 2013
    Messages:
    28
    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...
     

Share This Page