备份日志
[root@zabbix-server day6]# more back_log.sh
#!/bin/bash
date=`date +%Y%m%d`
if [ ! -f /tmp/log-$date.tar.gz ] ; then
tar -czf /tmp/log-$date.tar.gz /var/log
fi
[root@zabbix-server day6]# more mysqldump.sh
#!/bin/bash
date=$(date +%Y%m%d)
iuser=zabbix
ipass=123456
db=mysql
if [ ! -f /tmp/$db-$date.sql ] ; then
mysqldump -u$iuser --password=$"$ipass" $db > /tmp/$db-$date.sql
fi
[root@zabbix-server day6]# more bak_mysql.sh
#!/bin/bash
date=`date +%Y%m%d`
db_dir="/var/lib/mysql"
db="mysql"
[ ! -d /tmp/$db ] && mkdir /tmp/$db
for i in $(ls $db_dir/$db)
do
tar -zcf /tmp/$db/$i-$date.tar.gz $db_dir/$db/$i
done
inotify+rsync
[root@zabbix-server day6]# more isync.sh
#!/bin/bash
#备份源数据
FROM_DIR="/var/www/html/"
#
RSYNC_CMD="rsync -az --delete $FROM_DIR \
#备份到207下/var/www/html下
root@192.168.4.207:/var/www/html"
#实时差异备份,检查目录有a,d,m那么执行copy命令
while inotifywait -rqq -e modify,move,create,delete,attrib $FORM_DIR
do
$RSYNC_CMD
done &
|