客户端推送脚本
#!/bin/bash
Time=`date +%F-%w`
name=`hostname -I`
[ -d /backup] || mkdir /backup
[ -d /backup/bak ] || mkdir /backup/bak
rsync /var/spool/cron/root /backup/bak
rsync /etc/rc.d/rc.local /backup/bak
rsync /server/scripts /backup/bak
rsync /etc/sysconfig/iptables /backup/bak
cd /backup
mkdir $name
cd /backup
tar zcfP $Time.tar.gz bak
mv /backup/$Time* /backup/$name
cd /backup/$name
md5sum $Time* > $Time.txt
rsync -avz /backup/$name rsync_backup@192.168.200.10::backup --password-file=/etc/rsync.password
find -type f -mtime +7 | xargs rm -f
服务端检查脚本
#!/bin/bash
name=`date +%F-%w`
for i in `ls /backup`
do
cd /backup/$i
if [ -f $name.txt ];then
md5sum -c $name.txt
if [ $? -eq 0 ];then
echo "$i 传输成功"
else
echo "$i 传输失败"
fi
else
echo "$i 传输失败"
fi
find . -type f ! -name "*-1" -mtime +180 | xargs rm -f
done
mysql全备推送脚本
#!/bin/bash
Time=`date +%F-%w`
name=`hostname -I`
[ -d /backup] || mkdir /backup
[ -d /backup/bak ] || mkdir /backup/bak
mysqldump -uroot -p666666 --all-databases > /backup/bak
cd /backup
mkdir $name
cd /backup
tar zcfP $Time.tar.gz bak
mv /backup/$Time* /backup/$name
cd /backup/$name
md5sum $Time* > $Time.txt
rsync -avz /backup/$name rsync_backup@192.168.200.10::backup --password-file=/etc/rsync.password
find -type f -mtime +7 | xargs rm -f
监控nfs实时同步脚本
#!/bin/bash
Path=/data
backup_Server=192.168.200.10
/usr/bin/inotifywait -mrq --format '%w%f' -e create,close_write,delete /data | while read line
do
if [ -f $line ];then
rsync -az $line --delete rsync_backup@$backup_Server::nfsbackup --password-file=/etc/rsync.password
else
cd $Path &&\
rsync -az ./ --delete rsync_backup@$backup_Server::nfsbackup --password-file=/etc/rsync.password
fi
done
监控mysql实时同步
#!/bin/bash
Path=/usr/local/mysql/data
backup_Server=192.168.200.10
/usr/bin/inotifywait -mrq --format '%w%f' -e create,close_write,delete /usr/local/mysql/data | while read line
do
if [ -f $line ];then
rsync -az $line --delete rsync_backup@$backup_Server::mysqlbackup --password-file=/etc/rsync.password
else
cd $Path &&\
rsync -az ./ --delete rsync_backup@$backup_Server::mysqlbackup --password-file=/etc/rsync.password
fi
done
~