Here is the updated mysql dump script to share that i use on 5 years old servers ( with no downtime ) as a network backup server
#!/bin/bash
##### SETTING #####
MYUSER="root"
MYPWD="******"
DB="mysql **** **** ****"
DIR=$(date +%Y)/$(date +%B)
FAIL=backup_$(date +%d-%m-%Y)
HOST="mysql-local-server"
###################
cd /tmp
##check, repair and optimize before backup
mysqlcheck --auto-repair -m -o -B $DB -u $MYUSER -p$MYPWD -h $HOST
##backup now
mysqldump -c -x --add-drop-table --add-locks --database $DB -u $MYUSER -p$MYPWD -h $HOST > $FAIL.sql
if test -d "/home/data-backup/$DIR"
then
tar -jcf /home/data-backup/$DIR/$FAIL.tgz $FAIL.sql
#zip -9 -o /home/data-backup/$DIR/$FAIL.zip $FAIL.sql
#rar -a m5 /home/data-backup/$DIR/$FAIL.rar $FAIL.sql
rm -f /home/data-backup/latest.tgz
ln -s /home/data-backup/$DIR/$FAIL.tgz /home/data-backup/latest.tgz
# secondary backup to ftp server
# /skrip/ftpbackend
else
mkdir -p /home/data-backup/$DIR
tar -jcf /home/data-backup/$DIR/$FAIL.tgz $FAIL.sql
rm -f /home/data-backup/latest.tgz
ln -s /home/data-backup/$DIR/$FAIL.tgz /home/data-backup/latest.tgz
#secondary backup to ftp server
# /skrip/ftpbackend
fi
rm -f $FAIL
Windows and linux information and one stop centre for myself. Having difficulties to remember all things at once. This blog will remain be my references on the internet. Other people can take benefit from it. Thank you for visiting
Subscribe to:
Post Comments (Atom)
Simple Python Calculator This script will allows your to calculate the integers given with the chosen operation. You can add, substract, mu...
-
Skrip ini aku guna kat server aku.. backup mysql setiap hari. Hanya perlu ubah pada bahagian setting sahaja. chmod dan set cron untuk daily ...
-
There are many “solutions” for blocking your company employees accessing Yahoo Messenger, hi5, Facebook or any other distracting services, b...
-
when trying to apt-get update i got this error message :- W: There is no public key available for the following key IDs xxxxxxxxxxxx t...
No comments:
Post a Comment