# Description:
#   This script attempts to backup the data which is located in the 'slide'
#   database within the MySql Database Server on the American RedHat Linux Server.
#   The script will use the mysqldump script to extract the data from the 
#   mysql server.
#
#   This data is used by the 'slide' webdav server and is the data that users of 
#   the 'Alexis' XML editor application will see and edit
#
#   Other options for backing up the data include using the 'replication' features
#   of MySql, which has the advantage that the is not a large load on the 
#   MySql Server all at once.
#   Another option is to use the 'mysqlhotcopy' script which appears to have more
#   features than the mysqldump script but which has to be used on the same host
#   as the Database Server.
#
# Parameters:
#   'go'  there should be one parameter
#  
# Notes:
#   The 'go' parameter is simply to stop the user from accidentally running the script
#   The mysqldump utility seems to achieve its work in absolutely blinding speed. 
#   For example, in dumping a one megabyte database to a text file, there is no noticeably
#   delay for the script to 'return'
#
#   This script is probably 'scheduled' in the /etc/crontab file
#
# Author:
#   m.j.bishop

 if [ "$1" = "" ]
 then
   echo "usage: $0 go"
   cat $0 | sed -n "/^[ ]*#/p" 
   exit 1;
 fi

FILEBASENAME="mysql-slide-data"

cd /var/backup/mysql/

for i in $(seq 80 -1 1);
do 
  let j=$i+1; 
  cp $FILEBASENAME.tar.gz.$i $FILEBASENAME.tar.gz.$j; 
done; 


mysqldump --opt slide > $FILEBASENAME.txt

tar -zcvf $FILEBASENAME.tar.gz $FILEBASENAME.txt
mv -f $FILEBASENAME.tar.gz $FILEBASENAME.tar.gz.1
#cp /var/lib/cvs-repository.tar.gz .