zoukankan      html  css  js  c++  java
  • 服务器下自动备份MySQL

    Linux下
    service crond restart
    */10 * * * * /home/mysqlbackup.sh >/home/runssh.log
    
    backup.sh
    #bin/bash
    
    source ~/.bash_profile
    LANG=en_US.UTF-8
    
    cd /home/backup/gch
    
    Now=$(date +"%Y%m%d%H%M%S")
    File=backup-$Now.sql
    
    #最低优先级执行
    /bin/nice -n 19 /opt/lampp/bin/mysqldump -uroot -ptest  db > $File
    #压缩文件
    /bin/nice -n 19 tar -zPcf $File.tar.gz $File
    
    #删除sql文件 删除5天前的文件
    rm -rf *.sql
    find /home/backup -mtime +5 -name "*.sql.tar.gz" -exec rm -rf {} ;
    
    #自动备份到SVN服务器
    svn up
    svn add *
    svn commit -m 'backup'
    
    echo success
    Windows下backupMySQL.bat
    @echo off
    
    set h=%TIME:~0,2%
    set h=%h: =0%
    set "Time=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%%h%%TIME:~3,2%%TIME:~6,2%"
    set "File=backup_%Time%.sql"
    "C:Program FilesMySQLMySQL Server 5.5inmysqldump.exe" -uroot -paOulJpacChcUxVnc wbkchina> D:ackup\%File%
    
    "C:Program FilesWinRARWinRAR.exe" a -ibck -m5 -p12345 D:ackup\%TIME%.rar  D:ackup\%File%
    
    forfiles -p "D:ackup" -s -m *.sql -c "cmd /c del @path"
    forfiles -p "D:ackup" -s -m *.rar -d -3 -c "cmd /c del @path"
    
    @echo on
    
    
    
     
  • 相关阅读:
    一文搞懂字符集
    机器视觉之eVision
    PID调节
    激光切割质量主要影响因素
    155. 最小栈
    111.二叉树最小深度
    110. 平衡二叉树
    108.将有序数组转换为二叉搜索树
    107. 二叉树的层次遍历 II
    104. 二叉树的最大深度
  • 原文地址:https://www.cnblogs.com/adtuu/p/5549461.html
Copyright © 2011-2022 走看看