zoukankan      html  css  js  c++  java
  • 备份全网服务器数据

    客户端推送脚本

     
    1. #!/bin/bash
    2. Time=`date +%F-%w`
    3. name=`hostname -I`
    4. [ -d /backup] || mkdir /backup
    5. [ -d /backup/bak ] || mkdir /backup/bak
    6. rsync /var/spool/cron/root /backup/bak
    7. rsync /etc/rc.d/rc.local /backup/bak
    8. rsync /server/scripts /backup/bak
    9. rsync /etc/sysconfig/iptables /backup/bak
    10. cd /backup
    11. mkdir $name
    12. cd /backup
    13. tar zcfP $Time.tar.gz bak
    14. mv /backup/$Time* /backup/$name
    15. cd /backup/$name
    16. md5sum $Time* > $Time.txt
    17. rsync -avz /backup/$name rsync_backup@192.168.200.10::backup --password-file=/etc/rsync.password

    find -type f -mtime +7 | xargs rm -f

    服务端检查脚本

     
    1. #!/bin/bash
    2. name=`date +%F-%w`
    3. for i in `ls /backup`
    4. do
    5. cd /backup/$i
    6. if [ -f $name.txt ];then
    7. md5sum -c $name.txt
    8. if [ $? -eq 0 ];then
    9. echo "$i 传输成功"
    10. else
    11. echo "$i 传输失败"
    12. fi
    13. else
    14. echo "$i 传输失败"
    15. fi
    16. find . -type f ! -name "*-1" -mtime +180 | xargs rm -f

    done

    mysql全备推送脚本

     
    1. #!/bin/bash
    2. Time=`date +%F-%w`
    3. name=`hostname -I`
    4. [ -d /backup] || mkdir /backup
    5. [ -d /backup/bak ] || mkdir /backup/bak
    6. mysqldump -uroot -p666666 --all-databases > /backup/bak
    7. cd /backup
    8. mkdir $name
    9. cd /backup
    10. tar zcfP $Time.tar.gz bak
    11. mv /backup/$Time* /backup/$name
    12. cd /backup/$name
    13. md5sum $Time* > $Time.txt
    14. 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实时同步脚本

     
    1. #!/bin/bash
    2. Path=/data
    3. backup_Server=192.168.200.10
    4. /usr/bin/inotifywait -mrq --format '%w%f' -e create,close_write,delete /data | while read line
    5. do
    6. if [ -f $line ];then
    7. rsync -az $line --delete rsync_backup@$backup_Server::nfsbackup --password-file=/etc/rsync.password
    8. else
    9. cd $Path &&
    10. rsync -az ./ --delete rsync_backup@$backup_Server::nfsbackup --password-file=/etc/rsync.password
    11. fi

    done

    监控mysql实时同步

     
    1. #!/bin/bash
    2. Path=/usr/local/mysql/data
    3. backup_Server=192.168.200.10
    4. /usr/bin/inotifywait -mrq --format '%w%f' -e create,close_write,delete /usr/local/mysql/data | while read line
    5. do
    6. if [ -f $line ];then
    7. rsync -az $line --delete rsync_backup@$backup_Server::mysqlbackup --password-file=/etc/rsync.password
    8. else
    9. cd $Path &&
    10. rsync -az ./ --delete rsync_backup@$backup_Server::mysqlbackup --password-file=/etc/rsync.password
    11. fi
    12. done
    13. ~

    image_1crgu8b05tfp1t2u6q67qf5bj9.png-26.7kB

  • 相关阅读:
    Delphi 多线程知识
    程序员最后归宿是什么?30或35想转行?
    做技术的最终出路!
    路在何方?分析程序员人生之路
    一个垂直滚动的插件
    jQuery 动画中 缓动效果的应用
    [转]jQuery性能优化指南 I
    jQuery 标记当前函数 开始写一个简单的插件
    我发现我写的这俩函数太好用了~~
    jQuery浏览器版本判断
  • 原文地址:https://www.cnblogs.com/fengdou/p/9908412.html
Copyright © 2011-2022 走看看