This is an old revision of the document!


HOWTO Backup

This is a step-by-step tutorial on how to set up your DNS-323 for backup. The contents were copied from the following threads:

How To Back Up From Drive A To Drive B Once A Night

Why?

Automatically copying all data from one drive to the other can be used as part of a backup strategy. Some reports indicate that RAID1 is not altogether reliable, so this may be a better alternative. I have all my working data on Volume_1 and rotate backup disks in Volume_2, every month. I keep one disk away off site.

I was tired of trying software backups through my home network. This is by far the easiest and most efficient backup method I could find.

Software

  1. Firmware 1.03 or 1.04
  2. fonz's fun_plug 0.3, 0.4, or 0.5

(*Note, if you are using fun plug 0.4 you need to install rsync manually (see below) - with fun plug versions 0.3 and 0.5 rsync is automatically installed for you. Beware though that 0.5 is still in beta at this time).

Hardware

  1. dns323
  2. Hard Drives (a third can be used if you want to rotate backup disks in Volume_2 in order to keep one off site)

Procedure

Skip steps ONE and TWO if you have already installed and formatted the disks and fonz's fun_plug.

Step 1: Install Drives and Set the Correct Time

1) Install two disks into your dns323 (RHS for data and LHS for backup) and make sure they are formatted as standard drives, Volume_1 and Volume_2, via the dns323 admin page (mine is http://10.1.1.5). Do not set them up in any type of RAID configuration. Insert disk 1 (RHS drive bay) first and then disk 2 (LHS drive bay second).

If you have a third disk for off site backup purposes, you may also wish to format it now. Take out the RHS disk and insert the new backup disk. Format it in the same way. It is best to format a disk on its own in the dns323, without another disk being in the other bay which contains data.

2) In the dns323 admin, make sure you set the correct time (menu –> tools –> time). My time is set from the time of my local computer.

Step 2: Install fun_plug and the Telnet Client, puTTY

1) Install a fun_plug version as per instructions given by fonz (0.3 and 0.4 links below).

2) Download a telnet client, puTTY (link below), install it on your PC and telnet into the dns323. You should something similar to:

BusyBox v1.6.1 (2007-07-22 13:51:10 CEST) Built in shell (ash)
Enter 'help' for a list of built in commands.
/ #

You have successfully connected to the dns323.

3) Install rsync (only needed if you have installed fun plug version 0.4 - already installed on all other versions)

If you have installed fun plug 0.4 you need to then install rsync manually. Telnet into the dns323 and type the following at the /# prompt.

cd /mnt/HD_a2
mkdir tmp
cd tmp
wget http://www.inreto.de/dns323/fun-plug/0.4/addons/rsync-2.6.9.tgz
funpkg.sh rsync-2.6.9.tgz

Please note: If you are using fun plug 0.3 or 0.5, rsync will install automatically and you do not need to go through this step.

Step 3: Create a Scheduled Backup

There are three programs already installed which you will use:

  • vi - text editor in the BusyBox set of standard Linux single executable utilities (link below)
  • rsync – the backup program (links below)
  • cron – the scheduler (link below)

The first thing you need to do is create a file called 'editcron.sh' which is used to add your daily backup task to the scheduler, cron. This file is created and saved in the 'start' directory inside the main fun_plug.d directory (ffp directory in fun plug 0.5). This ensures the file will run on start up of the dns323.

1) After you have telneted into the dns323 and can see the # prompt, type in the following line of code. If you are using fun plug .05, replace the string “fun_plug.d” with “ffp”:

vi /mnt/HD_a2/fun_plug.d/start/editcron.sh

Once that is done, the new file 'editcron.sh' has been created, vi has started and you can edit the new file.

2) Press 'a' which takes you to vi edit mode. Type in the following lines of code (If you are using fun plug .05, replace the string “fun_plug.d” with “ffp”):

#!/bin/sh

CRONTXT=/mnt/HD_a2/crontab.txt

# start with existing crontab
/bin/crontab -l > $CRONTXT

# add the Rsync job to execute at 2:05 am - also create a logfile
/bin/echo "5 2 * * * /mnt/HD_a2/fun_plug.d/bin/rsync -rlptDv --delete /mnt/HD_a2 /mnt/HD_b2 >/mnt/HD_a2/fun_plug.d/log/rsync.last.log 2>&1" >> $CRONTXT

# install the new crontab
/bin/crontab $CRONTXT

# clean up
/bin/rm $CRONTXT

This code adds a rsync task to the scheduler.

In this example, everything from Volume_1 (/mnt/HD_a2) will be copied over to Volume_2 (/mnt/HD_b2) at 2.05am every night. The '2' and the '5' come from the beginning of the rsync task above. You can use any time that suits (24hr format) eg. 6.30 pm would be '30 18 * * *'

There are many options for rsync (links below). The time of 2.05am works best for me as no one is on the home network at that time.

A log file, rsync.last.log, will also be created in the 'log' directory inside the main fun_plug.d (fun plug 0.5 - ffp) directory. It will tell you which files were copied across successfully.

3) Once you have typed in the above code, press 'esc' to exit vi edit mode and then ':wq' to save and exit vi completely. You should be taken back to the # prompt and the file 'editcron.sh' will be created and saved in the 'start' directory inside the fun_plug.d (fun plug 0.5 ffp) directory.

4) For the fun_plug script to execute the 'editcron.sh' file, the 'editcron.sh' file must be executable. Type in the following command at the # prompt:

chmod a+x /mnt/HD_a2/fun_plug.d/start/editcron.sh

Step 4: Verify the Backup Task has been Added

Once the above is complete, double check that the rsync task has been added to the scheduler.

1) Reboot the dns323.

2) Telnet in and from the # prompt, type crontab –l (lowercase L). If everything has worked as it should you will see your rsync line as a scheduled task: (funplug 0.5 = ffp directory)

5 2 * * * /mnt/HD_a2/fun_plug.d/bin/rsync -rlptDv --delete /mnt/HD_a2 /mnt/HD_b2 >/mnt/HD_a2/fun_plug.d/log/rsync.last.log 2>&1

There should be three other scheduled tasks also listed, which has already been set up by the dns323. You don't need to worry about these.

When your scheduled time arrives, both HD lights on the dns323 start flashing away. Everything is working fine! Enjoy hassle free backups from now on!

Daily Snapshots (RSync Time Machine)

The only drawback for just backing up once a night is that if you accidentally corrupted or deleted a file and didn't realize it until a few days later, you have lost the file. Thankfully rsync has the ability take snapshots without taking up space for entire backups.

In a nutshell, this is a way of using rsync's hard link functionality to make a full backup, but creating hard links and saving space if the file already existed in the previous backup. The way hard links work, for those of you who aren't familiar, is like a ref-counting system where multiple files share the actual data. Until all hard links are deleted, the file will continue to exist.

This tutorial assumes you have already set up backup from drive A to drive B above.

Step 1: Create snapshot.sh

Using the same method mentioned above, create the file “snapshot.sh” script in /ffp/bin directory. Note that if you're running 0.3 or 0.4, replace anything with /ffp with /mnt/HD_a2/fun_plug.d for the rest of this tutorial.

#!/bin/sh

srcpath=/mnt/HD_a2
dstpath=/mnt/HD_b2
ffppath=/ffp
date=`date "+%Y%m%d_%H%M%S"`
mkdir $dstpath/$date
$ffppath/bin/rsync -rltEDivx --chmod=go-w --link-dest=$dstpath/current --exclude='workspace/' $srcpath $dstpath/$date > $ffppath/log/snapshot.log 2>&1
rm $dstpath/current
ln -s $date $dstpath/current

The instructions above only shows how to make a snapshot of the entire A drive into B drive. You can back up multiple directories by surrounding them with quotes single quotes:

srcpath='/mnt/HD_a2/Music /mnt/HD_a2/Docs'

Likewise, you can back up to a subfolder by changing the dstpath line:

dstpath=/mnt/HD_b2/backup

Finally, make the script executable:

chmod a+x /ffp/bin/snapshot.sh

Step 2: Modify editcron.sh

Then in editcron.sh, include this entry instead:

/bin/echo "00 2 * * * /ffp/bin/snapshot.sh" >> $CRONTXT

That's it! You're set up for daily backups! You can modify this cron entry if you want weekly or monthly backups instead.

Step 3: Verify the backup

If you want to verify that this works, run /ffp/bin/snapshot.sh. First back up may take a while, but when you see the hard drive stop, or that ps no longer shows the rsync processes, do:

# cd /mnt/HD_b2

# ls -al

You should see the first snapshot, looking something like this except with the current timestamp:

20080427_155301
current -> 20080427_155301

The first snapshot copies everything, which in my case is about 260 GB in my case. My second backup was quick and took about 25 MB extra for the hard links. I'm willing to spend a little HD space for the hard links and the convenience of having full copies of everything in every directory. Sure, it wil take up about 10 GB of overhead for a full year's worth of backups, but that's not too bad considering what I get in return, which is daily backups. I can always go back and delete the older backups and save just one per week or one per month.

After a few days, /mnt/HD_b2 should look something like this:

20080427_155301
20080428_020001
20080429_020001
current -> 20080429_020001

Each folder now contains a different snapshot, and you can delete the backup from any day, or recover any file from any day, without worrying about how it would affect the previous or the next backup! Congratulations, you now have your own Time Machine in your DNS-323!


Navigation

Personal Tools