#!/bin/bash
#Simple Database Backup and Rotation Utility
#Run from crontab nightly as root
#00 0    * * *   root    /root/bin/dump-dbs.sh
 
 
DATE=`date +%Y%m%d-%a`
DBS=`mysql -e "show databases" | awk '{ print $1 }' | tr '\n' ' ' | cut -b10-`
 
 
#Where to store your .sql backups
cd /root/MySQL-Backup
 
 
#Remove Previous Week's Backup
rm -f *-`date +%a`.sql
 
 
for i in $DBS ;
    do mysqldump --opt --allow-keywords --quote-names --result-file=$i-$DATE.sql $i;
done



I found this Perl one-liner here today. It’s a work of art.

du -k | sort -n | perl -ne 'if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024));printf  ("%6.1f\t%s\t%25s  %s\n",($1/(2**(10*$m))),(("K","M","G","T","P")[$m]),"*"x (1.5*$l),$2);}'





#!/bin/bash
#Show status for bonded IPs currently listed in /etc/ha.d/haresources
 
#We only want the second word (seq +2) through to the final four
#words (seq -4) in our haresources
cnt=`wc -w /etc/ha.d/haresources | cut -d" " -f1`
acnt=$(echo " $cnt - 4 " | bc -l)
 
addr=$(for i in `seq 2 $acnt` ;
do /bin/cat /etc/ha.d/haresources | cut -d" " -f$i | tr '\n' ' ' ;
done)
 
y=$(for x in $addr;
do echo $x | sed 's/IPaddr:://' ;
done)
 
for z in $y;
do echo " " ;
echo "Status for $z";
/etc/ha.d/resource.d/IPaddr2 $z status ;
done
 
echo " "
echo "Completed status for $acnt bonded address"
echo " "