zoukankan      html  css  js  c++  java
  • mysql 数据库备 及移动当天数据到历史表里 window下可用

    1 数据移动到历史表中,同时删除当天数据

    test-move-record.bat

    c:
    
    cd C:FQ_ManageServermysqlback
    
    
    mysql.exe  -h 10.71.1.236 -u"root" -p"" test --execute="replace into test_history select * from test;delete from test ;commit;select count(1),now() as date ,'move' from test_history;" >>C:FQ_ManageServermysqlbackhistory.txt
    
    echo ---------------move end----------------- >>C:FQ_ManageServermysqlbackhistory.txt
    exit
    

      

    结果
    
    count(1)	date	move
    4	2017-06-14 13:30:39	move
    ---------------move end----------------- 
    

     

    2 备份数据且把数据移动到历史表中

    start_backup.bat

    c:
    
    cd C:FQ_ManageServermysqlback
    
    mysqldump -h 10.71.1.236 -uroot -p test>C:FQ_ManageServermysqlbackdbbackupDB_backup_test%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2%
    start test-move-record.bat
    
    echo ---------------backup end-----------------  >>C:FQ_ManageServermysqlbackhistory.txt
    

      

    3 从历史表中恢复数据 和上面类似

    test-recovery-record.bat

     

    1 c:
    2 
    3 cd C:FQ_ManageServermysqlback
    4 
    5 
    6 mysql.exe  -h 10.71.1.236 -u"root" -p"" test --execute="replace into test select * from test_history ;commit;select count(1),now() as date, 'recovery' from test;" >>C:FQ_ManageServermysqlbackhistory.txt
    7 
    8 echo ---------------recovery end----------------- >>C:FQ_ManageServermysqlbackhistory.txt

    4 缺少从备份数据库中恢复功能

  • 相关阅读:
    xhtml+css (网站重构)
    一个典型的代码走查检查单
    谈谈单位时间内投票次数限制
    .NET性能优化方面的总结
    IE6.0、IE7.0 与 FireFox CSS
    vue3中使用 aggrid 表格组件
    基于predis高并发情况下实现频率控制的函数
    Redis之Centos下使用redis
    SVN的安装和使用
    Git配置教程
  • 原文地址:https://www.cnblogs.com/a9999/p/7008386.html
Copyright © 2011-2022 走看看