I needed to setup a script to backup myisam tables, so I thought I shall publish it on web too
########################
# Create Backup Folder #
########################
NOW=$(date +"%m_%d_%Y")
BACKUP_LOCATION="/u02/backup/dev/$NOW/"
mkdir -p `echo $BACKUP_LOCATION`
cd /u02/backup/dev/$NOW
########################################
# Array of databases we want to backup #
########################################
ARRAY="bugs my_company knowledge_base mysql wikidb"
MYSQL_HOTCOPY="/usr/bin/mysqlhotcopy -p xxxxx -q "
echo "----BACKUP STARTED @`date`"
#################################################
# Iterate through Array and Backup each of them #
################################################
for DATABASE in `echo $ARRAY`
do
echo "Taking backup of $DATABASE.."
$MYSQL_HOTCOPY $DATABASE $BACKUP_LOCATION
echo "Done.."
echo "Compressing backup directory using tar"
/bin/tar cfP $DATABASE.tar $BACKUP_LOCATION/$DATABASE
echo "Done.."
echo "Delete backup directory after tar command"
rm -fR $DATABASE
echo "Done.."
echo "Compressing $DATABASE.tar file using gzip"
/bin/gzip $DATABASE.tar
echo "done"
done
echo " ----- END -----@`date` "
##################################
No comments:
Post a Comment