NSLU2-Linux
view · edit · print · history

HowTo.FixTheDriveBackupForUnslungFirmware History

Hide minor edits - Show changes to markup

March 25, 2008, at 02:06 AM by D Yamaki -- Updated with uNSLUng-6.10-beta Example
Changed lines 168-171 from:

A Fully-Working Version for Unslung 6.8

Building on the preceding work, here's the script I've been using to do a drive-1-to-drive-2 copy with Unslung 6.8. Due to the way the Linksys R63 firmware handles the conf partitions, neither the above scripts, nor even the Linksys utility on the native firmware actually copy the conf partition data to the second drive! This script fixes that. Note that as written, this script uses the /opt/bin/nice utility to reduce the priority of the rsync doing the copy, in hopes that this will keep the unit somewhat responsive should the copy occur while something else is going on. If you don't have /opt/bin/nice installed, either install it (search using the Package Search Engine; used to be in coreutils), or edit the script to remove the string "/opt/bin/nice" whereever it appears. ~mwester

to:

A Fully-Working Version for V2.3R63-uNSLUng-6.10-beta

Here is the working script I use for DISK 1 to DISK 2, it's been working for about a week now. I followed the directions such as making the log directory (mkdir /share/hdd/log), adding the continue to fix Bourne Shell errors, installed rsync, and removed rsync script: ~D. Yamaki

Added lines 175-286:
 #!/bin/sh

 if [ -f /tmp/Scanning ]; then
 	/usr/sbin/set_log backup 1 1
 	exit 1
 fi

 if [ -f /tmp/Upgrading ]; then
 	/usr/sbin/set_log backup 1 2
 	exit 1
 fi

 if [ -f /tmp/Preparing ]; then
 	/usr/sbin/set_log backup 1 3
 	exit 1
 fi

 if [ -f /tmp/Moving ]; then
 	/usr/sbin/set_log backup 1 9 
 	exit 1
 fi

 if [ -f /tmp/DriveBackuping? ]; then
 	exit 1
 fi

 if [ -e /share/hdd/conf/.dongle ];then
 	continue
 else
 	/usr/sbin/set_log backup 0 1
 	exit 1
 fi


 if [ -e /share/flash/conf/.dongle ];then
 	continue
 else
 	/usr/sbin/set_log backup 0 1
 	exit 1
 fi

 F_HD1=`/bin/cat /share/hdd/conf/.dongle`
 F_HD2=`/bin/cat /share/flash/conf/.dongle`
 if [ "$F_HD1" != "$F_HD2" ]; then
 /usr/sbin/set_log backup 0 12
 exit 1
 fi

 /usr/sbin/CheckBackup?
 if [ $? = 1 ]; then
 	/usr/sbin/set_log backup 0 14
 	exit 1
 elif [ $? = 2 ];then
         /usr/sbin/set_log backup 0 15
         exit 1
 elif [ $? = 3 ];then
         /usr/sbin/set_log backup 0 12
         exit 1
 fi

 /usr/sbin/set_log backup 0 3
 touch /tmp/DriveBackuping?

 # CUSTOMIZATIONS HERE

 LOGDIR=/share/hdd/log
 # Keep seven days of backup logs named after days of the week

 LOGBASE=${LOGDIR}/rsync.`date +%A`

 #To make logging verbose, turn the "-q" into "-v"
 RSYNC="/opt/bin/rsync -a -H -q --delete"

 # Backup the conf directory, log to a specific file
 DIR=conf
 LOG=${LOGBASE}.${DIR}
 #
 # Syntax matters. Do not put ampersands (&) on the rsync command) 
 # It already runs in a crontab
 # The separation of logging also separates error messages into a separate file.
 # To keep it in the same file, use "2>${LOG}"

 ${RSYNC} /share/hdd/${DIR}/ /share/flash/${DIR} 1>${LOG} 2>${LOG}.err
 # If conf backup succeeds, backup the data dir
 if [ $? = 0 ]; then
   DIR=data
   LOG=${LOGBASE}.${DIR}
   ${RSYNC} /share/hdd/${DIR}/ /share/flash/${DIR} 1>${LOG} 2>${LOG}.err
 fi


 if [ $? = 0 ]; then
         /usr/sbin/set_log backup 0 4
 else
         /usr/sbin/set_log backup 0 13
 fi

 rm -f /tmp/DriveBackuping?

 /usr/sbin/CheckDiskFull

 =]

(:tableend:)


A Fully-Working Version for Unslung 6.8

Building on the preceding work, here's the script I've been using to do a drive-1-to-drive-2 copy with Unslung 6.8. Due to the way the Linksys R63 firmware handles the conf partitions, neither the above scripts, nor even the Linksys utility on the native firmware actually copy the conf partition data to the second drive! This script fixes that. Note that as written, this script uses the /opt/bin/nice utility to reduce the priority of the rsync doing the copy, in hopes that this will keep the unit somewhat responsive should the copy occur while something else is going on. If you don't have /opt/bin/nice installed, either install it (search using the Package Search Engine; used to be in coreutils), or edit the script to remove the string "/opt/bin/nice" whereever it appears. ~mwester

(:table border=0 width=100% bgcolor=#ffeeff:) (:cell:)

 [=
February 19, 2008, at 06:17 AM by woodpecker -- original drivertodrivercp - line 28 syntax error
Changed lines 11-12 from:

(Aside: this looks like a syntax error on Linksys' part. This is a Bourne shell - sh - script but the syntax looks like csh script.)

to:

(Aside: this looks like a syntax error on Linksys' part. This is a Bourne shell - sh - script but the syntax looks like csh script. Line 28 and 35 of original drivertodrivercp gets syntax error - add continue before else)

September 03, 2007, at 01:22 AM by mwester -- Heading added
Changed line 168 from:
to:

A Fully-Working Version for Unslung 6.8

September 03, 2007, at 01:21 AM by mwester -- formatting fix
Changed line 174 from:

[=

to:
 [=
September 03, 2007, at 01:20 AM by mwester -- Added a working 6.8 version of the backup script
Added lines 167-269:

Building on the preceding work, here's the script I've been using to do a drive-1-to-drive-2 copy with Unslung 6.8. Due to the way the Linksys R63 firmware handles the conf partitions, neither the above scripts, nor even the Linksys utility on the native firmware actually copy the conf partition data to the second drive! This script fixes that. Note that as written, this script uses the /opt/bin/nice utility to reduce the priority of the rsync doing the copy, in hopes that this will keep the unit somewhat responsive should the copy occur while something else is going on. If you don't have /opt/bin/nice installed, either install it (search using the Package Search Engine; used to be in coreutils), or edit the script to remove the string "/opt/bin/nice" whereever it appears. ~mwester

(:table border=0 width=100% bgcolor=#ffeeff:) (:cell:) #!/bin/sh if [ -f /tmp/Scanning ]; then /usr/sbin/set_log backup 1 1 exit 1 fi if [ -f /tmp/Upgrading ]; then /usr/sbin/set_log backup 1 2 exit 1 fi if [ -f /tmp/Preparing ]; then /usr/sbin/set_log backup 1 3 exit 1 fi if [ -f /tmp/Moving ]; then /usr/sbin/set_log backup 1 9 exit 1 fi if [ -f /tmp/DriveBackuping ]; then exit 1 fi if [ -e /share/hdd/conf/.dongle ];then else /usr/sbin/set_log backup 0 1 exit 1 fi if [ -e /share/flash/conf/.dongle ];then else /usr/sbin/set_log backup 0 1 exit 1 fi F_HD1=`/bin/cat /share/hdd/conf/.dongle` F_HD2=`/bin/cat /share/flash/conf/.dongle` if [ "$F_HD1" != "$F_HD2" ]; then /usr/sbin/set_log backup 0 12 exit 1 fi /usr/sbin/CheckBackup if [ $? = 1 ]; then /usr/sbin/set_log backup 0 14 exit 1 elif [ $? = 2 ];then /usr/sbin/set_log backup 0 15 exit 1 elif [ $? = 3 ];then /usr/sbin/set_log backup 0 12 exit 1 fi /usr/sbin/set_log backup 0 3 touch /tmp/DriveBackuping # Rotate the logs if [ -f /var/log/d2d.2.log ]; then rm /var/log/d2d.2.log; fi if [ -f /var/log/d2d.1.log ]; then mv /var/log/d2d.1.log /var/log/d2d.2.log; fi if [ -f /var/log/d2d.0.log ]; then mv /var/log/d2d.0.log /var/log/d2d.1.log; fi date >/var/log/d2d.0.log echo "------------------------------ Backup of conf:" >>/var/log/d2d.0.log echo "Creating mount directory." >>/var/log/d2d.0.log mkdir -p /mnt/tmpmnt_conf >>/var/log/d2d.0.log 2>&1 echo "Mounting /dev/sda1." >>/var/log/d2d.0.log mount /dev/sda2 /mnt/tmpmnt_conf >>/var/log/d2d.0.log 2>&1 echo "Performing rsync." >>/var/log/d2d.0.log /opt/bin/nice /opt/bin/rsync -a -l --delete --stats /share/hdd/conf/ /mnt/tmpmnt_conf >>/var/log/d2d.0.log 2>&1 ECODE=$? echo "Un-mounting /dev/sda1." >>/var/log/d2d.0.log umount /mnt/tmpmnt_conf >>/var/log/d2d.0.log 2>&1 if [ $ECODE = 0 ]; then echo "------------------------------ Backup of data:" >>/var/log/d2d.0.log echo "Performing rsync." >>/var/log/d2d.0.log /opt/bin/nice /opt/bin/rsync -a -l --delete --stats /share/hdd/data/ /share/flash/data >>/var/log/d2d.0.log 2>&1 ECODE=$? fi if [ $ECODE = 0 ]; then /usr/sbin/set_log backup 0 4 else /usr/sbin/set_log backup 0 13 fi date >>/var/log/d2d.0.log rm -f /tmp/DriveBackuping /usr/sbin/CheckDiskFull (:tableend:)

October 12, 2006, at 04:30 AM by unix_fan --
Deleted lines 166-167:

Clarification Questions about the wiki edits which split the logging into two files, and fix the rsync by removing the ampersands can be directed to unix_fan AT yahoo DOT com

October 12, 2006, at 04:20 AM by unix_fan -- Corrections to rsync, (mis)use of ampersand
Added lines 11-12:

(Aside: this looks like a syntax error on Linksys' part. This is a Bourne shell - sh - script but the syntax looks like csh script.)

Added lines 15-17:

Make a directory for backups logs: mkdir /share/hdd/log

Changed lines 24-43 from:

/opt/bin/rsync -a -H -q --delete /share/hdd/conf/ /share/flash/conf &>/dev/null

to:

LOGDIR=/share/hdd/log

  1. Keep seven days of backup logs named after days of the week

LOGBASE=${LOGDIR}/rsync.`date +%A`

  1. To make logging verbose, turn the "-q" into "-v"

RSYNC="/opt/bin/rsync -a -H -q --delete"

  1. Backup the conf directory, log to a specific file

DIR=conf LOG=${LOGBASE}.${DIR}

  1. Syntax matters. Do not put ampersands (&) on the rsync command)
  2. It already runs in a crontab
  3. The separation of logging also separates error messages into a separate file.
  4. To keep it in the same file, use "2>${LOG}"

${RSYNC} /share/hdd/${DIR}/ /share/flash/${DIR} 1>${LOG} 2>${LOG}.err

  1. If conf backup succeeds, backup the data dir
Changed lines 45-47 from:
        /opt/bin/rsync -a -H -q --delete /share/hdd/data/ /share/flash/data &>/dev/null
to:
  DIR=data
  LOG=${LOGBASE}.${DIR}
  ${RSYNC} /share/hdd/${DIR}/ /share/flash/${DIR} 1>${LOG} 2>${LOG}.err
Added line 50:
Changed lines 64-68 from:

Now the backup should be working fine again using the standard webinterface. One minor "bug" is that the entry in the backup log shows

2 12/19 23:00:00 Drive Backup: Backup complete.

2 12/19 23:00:00 Drive Backup: Backup start.

to:

Now the backup should be working fine again using the standard webinterface.

Removing the ampersand (&) from a previous version of these directions on the rsync line will insure the backup process - and subsequent msgs - wait for the the rsync to complete.

Deleted lines 67-68:

Where it looks like it doesn't work. But watching the drives shows that it really works. And since it does an incremental copy (copying only the changed or added files) it makes a copy fast (after an initial total copy).

Changed lines 77-78 from:

As you noticed when you start using rsync you lose having useful logging information. This is caused by the Linksys Webinterface, which adds &>/dev/null to every job added to the crontab. This can be fixed easy by adding a diversion script, which removes &>/dev/null from drivertodrivercp entries which are in the crontabfile. Below is an example of such a diversion script, create the file using one of the Unix style text editors and save as /unslung/rc.crond :-

to:

When you start using rsync you may lose having useful logging information. This is caused by the Linksys Webinterface, which adds &>/dev/null to every job added to the crontab. This can be fixed easy by adding the LOG information to the drivertodrivercp program, as shown above.

Another approach is a diversion script, which removes &>/dev/null from drivertodrivercp entries which are in the crontabfile. Below is an example of such a diversion script, create the file using one of the Unix style text editors and save as /unslung/rc.crond :-

Changed lines 165-168 from:

Chacko

to:

Chacko

Clarification Questions about the wiki edits which split the logging into two files, and fix the rsync by removing the ampersands can be directed to unix_fan AT yahoo DOT com

August 16, 2006, at 01:58 PM by Richard Letts -- fixed formatting errors
Changed lines 11-12 from:

In order to get the backup working again, you can install the rsync package using ipkg (ipkg install rsync), which put the rsync binary in /opt/bin.

to:

In order to get the backup working again, you can install the rsync package using ipkg (ipkg install rsync), which put the rsync binary in /opt/bin. A rsync daemon is automatically installed and started after reboot by the /opt/etc/init.d/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed.

Changed lines 16-31 from:

(:cell:)touch /tmp/DriveBackuping
/opt/bin/rsync -a -H -q --delete /share/hdd/conf/ /share/flash/conf &>/dev/null
if [ $? = 0 ]; then
/opt/bin/rsync -a -H -q --delete /share/hdd/data/ /share/flash/data &>/dev/null
fi

if [ $? = 0 ]; then
/usr/sbin/set_log backup 0 4
else
/usr/sbin/set_log backup 0 13
fi

rm -f /tmp/DriveBackuping

/usr/sbin/CheckDiskFull

to:

(:cell:)

 
touch /tmp/DriveBackuping
/opt/bin/rsync -a -H -q --delete /share/hdd/conf/ /share/flash/conf &>/dev/null
if [ $? = 0 ]; then
        /opt/bin/rsync -a -H -q --delete /share/hdd/data/ /share/flash/data &>/dev/null
fi

if [ $? = 0 ]; then
        /usr/sbin/set_log backup 0 4
else
        /usr/sbin/set_log backup 0 13
fi

rm -f /tmp/DriveBackuping

/usr/sbin/CheckDiskFull

Deleted lines 44-45:

One thing to add is that an rsync daemon is automatically installed and started after reboot by the /opt/etc/init.d/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed.

Deleted lines 77-105:

touch /tmp/DriveBackuping
/opt/bin/rsync -a -H -q --delete --no-detach /share/hdd/conf/ /share/flash/conf
if [ $? = 0 ]; then
/opt/bin/rsync -a -H -q --delete --no-detach /share/hdd/data/ /share/flash/data
fi

if [ $? = 0 ]; then
/usr/sbin/set_log backup 0 4
else
/usr/sbin/set_log backup 0 13
fi

rm -f /tmp/DriveBackuping

/usr/sbin/CheckDiskFull


When using this method, logging will be fully functional again!

It Works

Before the drive copy command works, the periodic automatic drive copy settings (just above the command button) has to be set first, with any time value such as every Saturday at 2am, and then SAVE button pushed. After the copy is finished, this setting can be disabled.

Chacko

Unslung to Disk2?

Change the script to:

Changed lines 79-94 from:

(:cell:)touch /tmp/DriveBackuping
/opt/bin/rsync -a -H -q --delete /share/flash/conf /share/hdd/conf
if [ $? = 0 ]; then
/opt/bin/rsync -a -H -q --delete /share/flash/data /share/hdd/data
fi

if [ $? = 0 ]; then
/usr/sbin/set_log backup 0 4
else
/usr/sbin/set_log backup 0 13
fi

rm -f /tmp/DriveBackuping

/usr/sbin/CheckDiskFull

to:

(:cell:)

 
touch /tmp/DriveBackuping
/opt/bin/rsync -a -H -q --delete /share/hdd/conf/ /share/flash/conf
if [ $? = 0 ]; then
        /opt/bin/rsync -a -H -q --delete /share/hdd/data/ /share/flash/data
fi

if [ $? = 0 ]; then
        /usr/sbin/set_log backup 0 4
else
        /usr/sbin/set_log backup 0 13
fi

rm -f /tmp/DriveBackuping

/usr/sbin/CheckDiskFull

Changed lines 98-99 from:
to:

When using this method, logging will be fully functional again!

It Works

Before the drive copy command works, the periodic automatic drive copy settings (just above the command button) has to be set first, with any time value such as every Saturday at 2am, and then SAVE button pushed. After the copy is finished, this setting can be disabled.

Chacko

Unslung to Disk2?

Change the script to: (:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)

 
touch /tmp/DriveBackuping
/opt/bin/rsync -a -H -q --delete /share/flash/conf/ /share/hdd/conf 
if [ $? = 0 ]; then
        /opt/bin/rsync -a -H -q --delete /share/flash/data/ /share/hdd/data  
fi

if [ $? = 0 ]; then
        /usr/sbin/set_log backup 0 4
else
        /usr/sbin/set_log backup 0 13
fi

rm -f /tmp/DriveBackuping

/usr/sbin/CheckDiskFull

(:tableend:)

RjL

August 16, 2006, at 01:40 PM by Richard Letts -- updated rsync options; added note for unslung to disk2
Changed lines 15-16 from:

@@touch /tmp/DriveBackuping
/opt/bin/rsync -a -l -q --delete --no-detach /share/hdd/conf/ /share/flash/conf &>/dev/null\\

to:

(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)@@touch /tmp/DriveBackuping
/opt/bin/rsync -a -H -q --delete /share/hdd/conf/ /share/flash/conf &>/dev/null\\

Changed line 19 from:
        /opt/bin/rsync -a -l -q --delete --no-detach /share/hdd/data/ /share/flash/data &>/dev/null\\
to:
        /opt/bin/rsync -a -H -q --delete /share/hdd/data/ /share/flash/data &>/dev/null\\
Changed lines 31-32 from:

\\

to:

(:tableend:)

Changed lines 43-48 from:

One thing to add is that an rsync daemon is automatically installed and started after reboot by the /opt/etc/init.d/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed. If you do this though, you will need remove the "--no-detach" from the lines above. This parameter can only be used when an rsync daemon is running. Otherwise logs will say it ran, but it really did not. But if you want to rsync to the NSLU2 through the network you may want to keep it.

In newer versions of rsync (at least by 2.6.7-1) you have to remove the "--no-detach" option EVEN with the daemon running. Again, it appears to run like the previous comment, but just errors out. Maybe this is a bug in rsync, I dunno, but its what I needed to do to make rsync work. I think that the biggest lesson learned here is that if you upgrade rsync on your slug verify that the backups still work.

Have fun!

to:

One thing to add is that an rsync daemon is automatically installed and started after reboot by the /opt/etc/init.d/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed.

The --no-detach option was in the original version of this script and is not required: it is only valid when running as a daemon process and was ignored in non-daemon mode before version 2.6.7-1 gives an error from 2.6.7-1 and later.

The -l option (create symbolic links) was in the original version of this script and is not required: it is implied by the '-a' option

The -H option was missing from the was in the original version of this script; if you use hard links (e.g. backuppc or rsnapshot) then the files get duplicated instead of a hard link used. This slows down the script slightly, but if you're using hardlink you're going to use it (or the destination disk will not be large enough)

Changed line 80 from:

/opt/bin/rsync -a -l -q --delete --no-detach /share/hdd/conf/ /share/flash/conf\\

to:

/opt/bin/rsync -a -H -q --delete --no-detach /share/hdd/conf/ /share/flash/conf\\

Changed line 82 from:
        /opt/bin/rsync -a -l -q --delete --no-detach /share/hdd/data/ /share/flash/data\\
to:
        /opt/bin/rsync -a -H -q --delete --no-detach /share/hdd/data/ /share/flash/data\\
Deleted lines 97-109:

It works - mostly

I use rsnapshot which uses rsync and also creates hard links. I changed the lines above to read like so:

touch /tmp/DriveBackuping
/opt/bin/rsync -a -l -q -H --delete --no-detach /share/hdd/conf/ /share/flash/conf
if [ $? = 0 ]; then
/opt/bin/rsync -a -l -q -H --delete --no-detach /share/hdd/data/ /share/flash/data
fi
The -H appears to fix the hard link backups. Can someone with experience confirm that it is correct and update the code above.

Todd

Changed lines 100-101 from:

I have tried this, and it works. Before the drive copy command works, the periodic automatic drive copy settings (just above the command button) has to be set first, with any time value such as every Saturday at 2am, and then SAVE button pushed. After the copy is finished, this setting can be disabled.

to:

Before the drive copy command works, the periodic automatic drive copy settings (just above the command button) has to be set first, with any time value such as every Saturday at 2am, and then SAVE button pushed. After the copy is finished, this setting can be disabled.

Added lines 104-126:

Unslung to Disk2?

Change the script to: (:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)touch /tmp/DriveBackuping
/opt/bin/rsync -a -H -q --delete /share/flash/conf /share/hdd/conf
if [ $? = 0 ]; then
/opt/bin/rsync -a -H -q --delete /share/flash/data /share/hdd/data
fi

if [ $? = 0 ]; then
/usr/sbin/set_log backup 0 4
else
/usr/sbin/set_log backup 0 13
fi

rm -f /tmp/DriveBackuping

/usr/sbin/CheckDiskFull

(:tableend:)

/RjL?

June 25, 2006, at 01:34 PM by Todd -- added -H fix for hard links
Added lines 93-105:

It works - mostly

I use rsnapshot which uses rsync and also creates hard links. I changed the lines above to read like so:

touch /tmp/DriveBackuping
/opt/bin/rsync -a -l -q -H --delete --no-detach /share/hdd/conf/ /share/flash/conf
if [ $? = 0 ]; then
/opt/bin/rsync -a -l -q -H --delete --no-detach /share/hdd/data/ /share/flash/data
fi
The -H appears to fix the hard link backups. Can someone with experience confirm that it is correct and update the code above.

Todd

June 11, 2006, at 05:07 PM by Rob Lockhart -- change driv1 to drive1
Changed lines 101-102 from:

A question: Does anybody know how to do with a script (Without using the admin web page) what the above SAVE settings does? With that, one can simply have a command to (a) set the save settings, (b) copy driv1 to drive2 with /usr/sbin/drivertodrivercp, and then (c) reset the SAVE settings back so it wont automatically do copy later.

to:

A question: Does anybody know how to do with a script (Without using the admin web page) what the above SAVE settings does? With that, one can simply have a command to (a) set the save settings, (b) copy drive1 to drive2 with /usr/sbin/drivertodrivercp, and then (c) reset the SAVE settings back so it wont automatically do copy later.

June 11, 2006, at 04:39 PM by Rob Lockhart -- usefull -> useful
Changed lines 49-50 from:

As you noticed when you start using rsync you lose having usefull logging information. This is caused by the Linksys Webinterface, which adds &>/dev/null to every job added to the crontab. This can be fixed easy by adding a diversion script, which removes &>/dev/null from drivertodrivercp entries which are in the crontabfile. Below is an example of such a diversion script, create the file using one of the Unix style text editors and save as /unslung/rc.crond :-

to:

As you noticed when you start using rsync you lose having useful logging information. This is caused by the Linksys Webinterface, which adds &>/dev/null to every job added to the crontab. This can be fixed easy by adding a diversion script, which removes &>/dev/null from drivertodrivercp entries which are in the crontabfile. Below is an example of such a diversion script, create the file using one of the Unix style text editors and save as /unslung/rc.crond :-

March 26, 2006, at 12:05 PM by Chris Parker -- remove \\\"--no-detach\\\" for later versions of rsync
Added lines 43-44:

In newer versions of rsync (at least by 2.6.7-1) you have to remove the "--no-detach" option EVEN with the daemon running. Again, it appears to run like the previous comment, but just errors out. Maybe this is a bug in rsync, I dunno, but its what I needed to do to make rsync work. I think that the biggest lesson learned here is that if you upgrade rsync on your slug verify that the backups still work.

March 24, 2006, at 06:35 PM by RobHam -- Unslung script section enhanced
Changed lines 47-48 from:

As you noticed when you start using rsync you lose having usefull logging information. This is caused by the Linksys Webinterface, which adds &>/dev/null to every job added to the crontab. This can be fixed easy by adding a diversion script, which removes &>/dev/null from drivertodrivercp entries which are in the crontabfile. Below is an example of such a diversion script:

to:

As you noticed when you start using rsync you lose having usefull logging information. This is caused by the Linksys Webinterface, which adds &>/dev/null to every job added to the crontab. This can be fixed easy by adding a diversion script, which removes &>/dev/null from drivertodrivercp entries which are in the crontabfile. Below is an example of such a diversion script, create the file using one of the Unix style text editors and save as /unslung/rc.crond :-

Added lines 55-56:
  1. /unslung/rc.crond
February 10, 2006, at 11:58 AM by othell -- Not using the --no-detach parameter when the daemon is not running
Changed lines 41-42 from:

One thing to add is that an rsync daemon is automatically installed and started after reboot by the /opt/etc/init.d/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed. If you want to rsync to the NSLU2 through the network you may want to keep it.

to:

One thing to add is that an rsync daemon is automatically installed and started after reboot by the /opt/etc/init.d/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed. If you do this though, you will need remove the "--no-detach" from the lines above. This parameter can only be used when an rsync daemon is running. Otherwise logs will say it ran, but it really did not. But if you want to rsync to the NSLU2 through the network you may want to keep it.

January 24, 2006, at 05:17 PM by Mark -- Enable loging when using rsync for backup
Added lines 45-88:

Fix the minor logging bug by a Diversion script

As you noticed when you start using rsync you lose having usefull logging information. This is caused by the Linksys Webinterface, which adds &>/dev/null to every job added to the crontab. This can be fixed easy by adding a diversion script, which removes &>/dev/null from drivertodrivercp entries which are in the crontabfile. Below is an example of such a diversion script:

(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)

 
#! /bin/sh
# Diversion script: customize before starting crond
#
# Reason: fix the log when using rsync for jobs added from linksys webgui
#
if [ ! -e /etc/crontab.orig ]; then cp -p /etc/crontab /etc/crontab.orig; fi
sed -i -e 's_/usr/sbin/drivertodrivercp   &>/dev/null_/usr/sbin/drivertodrivercp_' /etc/crontab

#
# Continue to start crond

return 1
# EOF - include this line

(:tableend:)

When using this method, you must edit your drivertodrivercp script and remove the &>/dev/null entries. It then reads (picking up from the touch /tmp/DriveBackupping line):

touch /tmp/DriveBackuping
/opt/bin/rsync -a -l -q --delete --no-detach /share/hdd/conf/ /share/flash/conf
if [ $? = 0 ]; then
/opt/bin/rsync -a -l -q --delete --no-detach /share/hdd/data/ /share/flash/data
fi

if [ $? = 0 ]; then
/usr/sbin/set_log backup 0 4
else
/usr/sbin/set_log backup 0 13
fi

rm -f /tmp/DriveBackuping

/usr/sbin/CheckDiskFull


When using this method, logging will be fully functional again!

Deleted line 94:
January 09, 2006, at 04:01 PM by Chacko -- A confirmation and a couple of related questions
Changed lines 43-60 from:

Have fun!

to:

Have fun!

It Works

I have tried this, and it works. Before the drive copy command works, the periodic automatic drive copy settings (just above the command button) has to be set first, with any time value such as every Saturday at 2am, and then SAVE button pushed. After the copy is finished, this setting can be disabled.

Chacko

How to further automate this?

A question: Does anybody know how to do with a script (Without using the admin web page) what the above SAVE settings does? With that, one can simply have a command to (a) set the save settings, (b) copy driv1 to drive2 with /usr/sbin/drivertodrivercp, and then (c) reset the SAVE settings back so it wont automatically do copy later.

Another question: Is it possible to plug in the second hard disk drive into port DISK2? when unSlung is already up and running, and then mount this drive? Currently I see the second drive only if unSlung is booted up with the second drive (as well as, of course the unSlung drive in DISK1?).

Also what is the procedure for powering down DISK2?, before it can be unplugged, while unSlung is still running?

Chacko

May 20, 2005, at 09:22 AM by peecock41 --
Changed line 27 from:

rm -f /tmp/DriveBackuping?\\

to:

rm -f /tmp/DriveBackuping\\

Changed lines 29-30 from:

/usr/sbin/CheckDiskFull@@

to:

/usr/sbin/CheckDiskFull@@
\\

May 17, 2005, at 06:56 PM by peecock41 --
Changed lines 1-2 from:

When you upgraded the firmware to unslung, you will notice that the Drive Backup option doesn't work anymore. Unslung firmware uses symbolic links which the backup program made by LinkSys? can't handle.

to:

When you upgraded the firmware to unslung, you will notice that the Drive Backup option doesn't work anymore. Unslung firmware uses symbolic links which the backup program made by LinkSys can't handle.

January 17, 2005, at 09:02 AM by bobtm --
Changed line 13 from:

Now change the drivertodrivercp script in the last bit (picking up from the touch /tmp/DriveBackupping? line):

to:

Now change the drivertodrivercp script in the last bit (picking up from the touch /tmp/DriveBackupping line):

Changed line 15 from:

@@touch /tmp/DriveBackuping?\\

to:

@@touch /tmp/DriveBackuping\\

January 16, 2005, at 09:44 PM by DaveHooper --
Changed lines 15-29 from:

touch /tmp/DriveBackuping?

to:

touch /tmp/DriveBackuping?
/opt/bin/rsync -a -l -q --delete --no-detach /share/hdd/conf/ /share/flash/conf &>/dev/null
if [ $? = 0 ]; then
/opt/bin/rsync -a -l -q --delete --no-detach /share/hdd/data/ /share/flash/data &>/dev/null
fi

if [ $? = 0 ]; then
/usr/sbin/set_log backup 0 4
else
/usr/sbin/set_log backup 0 13
fi

rm -f /tmp/DriveBackuping?

/usr/sbin/CheckDiskFull
\\

Changed lines 31-53 from:

/opt/bin/rsync -a -l -q --delete --no-detach /share/hdd/conf/ /share/flash/conf &>/dev/null

if [ $? = 0 ]; then

/opt/bin/rsync -a -l -q --delete --no-detach /share/hdd/data/ /share/flash/data &>/dev/null

fi

if [ $? = 0 ]; then

/usr/sbin/set_log backup 0 4

else

/usr/sbin/set_log backup 0 13

fi

rm -f /tmp/DriveBackuping?

/usr/sbin/CheckDiskFull

(sorry, the Wiki messes up the indented spaces). A few notes on these lines: 1) Note the end slash of the /share/hdd/data/ part, that's important. 2) Note that there is no such slash behind the /share/flash/data part, that's correct. Don't forget the &>/dev/null at the end of the command. If you forget that, the command won't run as a cronjob, although it runs by executing it by hand.

to:

A few notes on these lines: 1) Note the end slash of the /share/hdd/data/ part, that's important. 2) Note that there is no such slash behind the /share/flash/data part, that's correct. Don't forget the &>/dev/null at the end of the command. If you forget that, the command won't run as a cronjob, although it runs by executing it by hand.

January 16, 2005, at 07:56 PM by peecock41 --
Changed line 49 from:

One thing to add is that an rsync daemon is automically installed and started after reboot by the /opt/etc/init.d/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed. If you want to rsync to the NSLU2 through the network you can keep it.

to:

One thing to add is that an rsync daemon is automatically installed and started after reboot by the /opt/etc/init.d/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed. If you want to rsync to the NSLU2 through the network you may want to keep it.

December 29, 2004, at 09:01 PM by peecock41 --
Changed line 39 from:

(sorry, the Wiki messes up the indented spaces)

to:

(sorry, the Wiki messes up the indented spaces). A few notes on these lines: 1) Note the end slash of the /share/hdd/data/ part, that's important. 2) Note that there is no such slash behind the /share/flash/data part, that's correct. Don't forget the &>/dev/null at the end of the command. If you forget that, the command won't run as a cronjob, although it runs by executing it by hand.

December 29, 2004, at 07:21 PM by peecock41 --
Changed line 49 from:

One thing to add is that an rsync daemon is automically installed and started after reboot by the /opt/etc/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed. If you want to rsync to the NSLU2 through the network you can keep it.

to:

One thing to add is that an rsync daemon is automically installed and started after reboot by the /opt/etc/init.d/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed. If you want to rsync to the NSLU2 through the network you can keep it.

December 29, 2004, at 07:20 PM by peecock41 --
Added line 44:
December 29, 2004, at 07:19 PM by peecock41 --
Changed line 41 from:

Now the backup should be working fine again. One minor "bug" is that the entry in the backup log shows

to:

Now the backup should be working fine again using the standard webinterface. One minor "bug" is that the entry in the backup log shows

December 29, 2004, at 07:14 PM by peecock41 --
Added lines 39-40:

(sorry, the Wiki messes up the indented spaces)

Changed lines 46-48 from:

Where it looks like it doesn't work. But watching the drives shows that it really works. And since it does an incremental copy (copying only the changed or added files) makes it very fast (after an initial total copy).

to:

Where it looks like it doesn't work. But watching the drives shows that it really works. And since it does an incremental copy (copying only the changed or added files) it makes a copy fast (after an initial total copy).

One thing to add is that an rsync daemon is automically installed and started after reboot by the /opt/etc/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed. If you want to rsync to the NSLU2 through the network you can keep it.

Changed line 50 from:

One thing to add is that an rsync daemon is automically installed and started after reboot by the /opt/etc/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed. If you want to rsync to the NSLU2, then you can keep it.

to:

Have fun!

December 29, 2004, at 07:11 PM by peecock41 --
Added line 16:
Added line 18:
Added line 20:
Added line 22:
Added line 24:
Added line 26:
Added line 28:
Added line 30:
Added line 32:
Added line 34:
Added line 36:
December 29, 2004, at 07:11 PM by peecock41 --
Changed lines 1-35 from:
to:

When you upgraded the firmware to unslung, you will notice that the Drive Backup option doesn't work anymore. Unslung firmware uses symbolic links which the backup program made by LinkSys? can't handle.

Now let's see how the backup worked before, and see how to fix it.

First, when using the button Start Backup Now under the Drive Backup, then the script /usr/sbin/drivertodrivercp is run. At the near end, after doing loads of checks to see if nothing else is messing up your disk, the binary drive_backup is run. You will notice that the backup is done instantaneously, according to the logging. Trying drivertodrivercp by hand (command line) shows a Segmentation Fault error when running the drive_backup binary.

When you set a time to do the backup an entry is made in the crontab (/etc/crontab):

0 4 * * * root /usr/sbin/drivertodrivercp &>/dev/null

In order to get the backup working again, you can install the rsync package using ipkg (ipkg install rsync), which put the rsync binary in /opt/bin.

Now change the drivertodrivercp script in the last bit (picking up from the touch /tmp/DriveBackupping? line):

touch /tmp/DriveBackuping? /opt/bin/rsync -a -l -q --delete --no-detach /share/hdd/conf/ /share/flash/conf &>/dev/null if [ $? = 0 ]; then /opt/bin/rsync -a -l -q --delete --no-detach /share/hdd/data/ /share/flash/data &>/dev/null fi if [ $? = 0 ]; then /usr/sbin/set_log backup 0 4 else /usr/sbin/set_log backup 0 13 fi rm -f /tmp/DriveBackuping? /usr/sbin/CheckDiskFull

Now the backup should be working fine again. One minor "bug" is that the entry in the backup log shows

2 12/19 23:00:00 Drive Backup: Backup complete. 2 12/19 23:00:00 Drive Backup: Backup start.

Where it looks like it doesn't work. But watching the drives shows that it really works. And since it does an incremental copy (copying only the changed or added files) makes it very fast (after an initial total copy).

One thing to add is that an rsync daemon is automically installed and started after reboot by the /opt/etc/S##rsync.rc script. For only local copies (from disk 1 to 2) this isn't needed and uses up valuable resources (memory!), so this script can be removed. If you want to rsync to the NSLU2, then you can keep it.

Page last modified on March 25, 2008, at 02:06 AM