Windows backup using DLINK DNS-323

1. Install CWRsync: http://sourceforge.net/project/showfiles.php?group_id=69227&package_id=68081

2. Create ssh-rsa for the server(password-less rsync)
cd "c:\program files\cwrsync\bin"
ssh-keygen -t rsa -N '' (hit enter twice)

3. Upload your generated key to the backup server
rsync -av "/cygdrive/c/documents and settings/administrator/.ssh/id_rsa.pub" root@ipaddress:/home/root/

4. SSH to your DNS-323 and copy the new id_rsa.pub to authorized_keys
#cat /home/root/id_rsa.pub >> /home/root/.ssh/authorized_keys

5. Create a Batch file in your Windows


@ECHO OFF
REM *****************************************************************
REM
REM CWRSYNC.CMD - Batch file template to start your rsync command (s).
REM
REM By Tevfik K. (http://itefix.no)
REM *****************************************************************

REM This is where we can find our .ssh

SET HOME=C:\Documents and Settings\Administrator

REM Make environment variable changes local to this batch file
SETLOCAL

REM ** CUSTOMIZE ** Specify where to find rsync and related files (C:\CWRSYNC)
SET CWRSYNCHOME=%PROGRAMFILES%\CWRSYNC

REM Set CYGWIN variable to 'nontsec'. That makes sure that permissions
REM on your windows machine are not updated as a side effect of cygwin
REM operations.
SET CYGWIN=nontsec

REM Set HOME variable to your windows home directory. That makes sure
REM that ssh command creates known_hosts in a directory you have access.
SET HOME=%HOMEDRIVE%%HOMEPATH%

REM Make cwRsync home as a part of system PATH to find required DLLs
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%\BIN;%PATH%

REM Windows paths may contain a colon (:) as a part of drive designation and
REM backslashes (example c:\, g:\). However, in rsync syntax, a colon in a
REM path means searching for a remote host. Solution: use absolute path 'a la unix',
REM replace backslashes (\) with slashes (/) and put -/cygdrive/- in front of the
REM drive letter:
REM
REM Example : C:\WORK\* --> /cygdrive/c/work/*
REM
REM Example 1 - rsync recursively to a unix server with an openssh server :
REM
REM rsync -r /cygdrive/c/work/ remotehost:/home/user/work/
REM
REM Example 2 - Local rsync recursively
REM
REM rsync -r /cygdrive/c/work/ /cygdrive/d/work/doc/
REM
REM Example 3 - rsync to an rsync server recursively :
REM (Double colons?? YES!!)
REM
REM rsync -r /cygdrive/c/doc/ remotehost::module/doc
REM
REM Rsync is a very powerful tool. Please look at documentation for other options.
REM

REM ** CUSTOMIZE ** Enter your rsync command(s) here
REM You want to copy C:\Documents and Settings\Administrator\My Documents\ to DNS-323
rsync --progress -aurp --delete "/cygdrive/c/Documents and Settings/Administrator/My Documents/" root@dns.ip.address:/mnt/HD_a2/Mydocs/




6. Sched the backup using Windows Task Scheduler

By penoi on Tuesday, April 1, 2008 | | 4 comments
4 responses to “Windows backup using DLINK DNS-323”
  1. Penoi says:

    Problem is after reboot, your dlink will not restore your .ssh/authorized_keys. This is a quick fix to resolve this issue

    1. copy your authorized_keys
    #cp /home/root/.ssh/authorized_keys /mnt/HD_a2/

    2. create /mnt/HD_a2/fun_plug.d/dlinkssh.sh
    #######################################################
    #!/bin/sh
    #Author: penoi
    #Date: 04.02.2008
    #Purpose: Configure SSH authorized keys for DLINK DNS-323

    mkdir /home/root/.ssh
    copy /mnt/HD_a2/authorized_keys /home/root/.ssh/
    chmod 600 /home/root/.ssh/authorized_keys

    #######################################################

    3. configure dlinkssh.sh to start at reboot
    #chmod a+x /mnt/HD_a2/fun_plug.d/dlinkssh.sh

  2. anonymous says:

    Because I'm using FFP 0.5, I created dlinkssh.sh in /mnt/HD_a2/ffp/start .

    For those clueless like me, authorized_keys is a file not folder.

    Thanks for the article Penoy.

  3. anonymous says:

    Thanks for the step-by-step instruction.

    Rsync is running fine but it'll always prompt for password. How to make rsync password-less?

  4. anonymous says:

    change:

    copy /mnt/HD_a2/authorized_keys /home/root/.ssh/

    to:

    cp /mnt/HD_a2/authorized_keys /home/root/.ssh/

    in penoi's script.