DNS-323 for Central Data Storage
DNS-323 as NAS
The DNS-323 by D-Link is a 2-bay network storage enclosure.
- 2 SATA harddisk drive slots, different modes of combined or separate operation
- Gigabit Ethernet port
- USB port to serve a printer to the network
- Extensible Linux FW
The last point, “hacked” Linux FW, was an important criterion for this selection. The DNS-323 is discussed in a couple of forums and additional SW is published. It is also possible to logon the shell for troubleshooting and configuration.
RAID or not RAID?
The first idea was to have a very safe place for my data and configure the HDs in RAID1 mode, e.g. have both disks mirrored. Reading through some forums, I read the mantra “RAID is no safe copy” on and on. So, why not?
One of the reasons is that the restoration procedure after replacing a faulty disk is unpredictable. I read that in some cases the new empty disk was mirrored to the good data disk! Your last good data are part of a working system, which tries to restore data to both disks. This is not a safe place under all circumstances.
The other reason is, that a good share of lost data is lost due to human error! Your deleted files are deleted on both disks in case of RAID!
Solution: Daily Snapshots to the second disk
I configured both disks as totally independent disks. They appear under CIFS as different volumes.
A shell script started nightly at 2am by CRON makes a safe copy from disk1 (the working disk) to disk 2 (the backup disk) using rsync.
Only disk1 is used for all user operations. Disk2 is normally power down due to its idle state, stays cool and should have a long life. Disk2 is only used once per night.
Actually rsync creates a new directory with all data every night. BUT, it uses hardlinks in case the file exists already. This means after the first full safe copy, it copies only changed files over to disk2.
In case the data on disk2 are needed for recovery, there is a directory for each day. It looks like a full daily backup. But because of the hardlinks, there are physically no duplicate files. The data volume on disk2 is the same as on disk1 plus alls the deltas and some directory overhead!
Some files missing? Let’s check on disk2 the directory of 3 days ago!
- Daily snapshots available
- Disk2 stays cool
- The complete disk2 could be used for off-site archiving
This sounds better than RAID! No worries, my data get safe copied automatically every night.
The Script
#!/bin/sh # Set Source Path # Back up the A drive (HD_a2) by identifying the source path as /mnt/HD_a2 srcpath=/mnt/HD_a2 # Back up multiple directories by surrounding a list with single quotes (i.e., srcpath='/mnt/HD_a2/Music /mnt/HD_a2/Docs') # srcpath='/mnt/HD_a2/Music /mnt/HD_a2/Docs' # Set the Destination Path dstpath=/mnt/HD_b2/Backup_NAS # Set path to Fun_Plug files # Fun_Plug 3.0 or 4.0 # ffppath=/mnt/HD_a2/fun_plug.d # Fun_Plug 5.0 ffppath=/ffp date=`date "+%Y%m%d_%H%M%S"` mkdir $dstpath/$date $ffppath/bin/rsync -avx --link-dest=$dstpath/current $srcpath $dstpath/$date > $ffppath/log/snapshot.log 2>&1 var=`ls -1A $dstpath/$date | wc -l` if [ $var -ne 0 ] then rm $dstpath/current ln -s $date $dstpath/current fi
This file needs to stored on the HD. Then the CRONTAB needs to be update by following script which will be executed once after startup:
#!/bin/sh CRONTXT=/mnt/HD_a2/crontab.txt # start with existing crontab /bin/crontab -l > $CRONTXT # add the Rsync job to execute at 2:00 am /bin/echo "0 2 * * * /ffp/bin/snapshot.sh" >> $CRONTXT # install the new crontab /bin/crontab $CRONTXT # clean up /bin/rm $CRONTXT
The daily snapshot, or “rsync time machine” script has been designed by user raid123 and is discussed here:
Before the script can be installed, we need to get access to the Linux, which has normally no open interface. A good way to get a telnet client (and later SSH, if needed) and the busybox shell running on the DNS-323 is to use Fonz’s fun_plug extension. fun_plug is loaded during the DNS-323 startup and opens the door for further extensions. More here: