I want to spread out the backup process over a longer period of time to lower the load on the box.

If you wish to keep your load average below a certain point, and not allow backups to run right away if the load is over a certain point, the followin script will help. It will check your load average before each backup file is created. If the load is too high, it will wait for 5 seconds, then check again. It will continue this process until the load is low enough, then create the backup. If the load is not below the threshold after 20 attempts, a non-zero value is returned and that user backup is skipped and an error returned in DA.

To use this script, place the following code into the file:

/usr/local/directadmin/scripts/custom/user_backup_pre.sh

#!/bin/sh
MAXTRIES=20
MAXLOAD=8.00

function highload()
{
   LOAD=`cat /proc/loadavg | cut -d\ -f1`
   echo "$LOAD > $MAXLOAD" | bc
}

TRIES=0
while [ `highload` -eq 1 ];
do
   sleep 5;
   if [ "$TRIES" -ge "$MAXTRIES" ]; then
     echo "system load above $MAXLOAD for $MAXTRIES attempts. Aborting.";
     exit 1;
   fi
   ((TRIES++))
done;
exit 0;

then chmod the new user_backup_pre.sh script to 755.

Related

 
config/spread.txt · Last modified: 2010/02/28 15:32 by muscardin
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Please visit Automatic Backlinks to start earning free backlinks Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki