首页 > 数据库
一言推荐::D 获取中...

mysql数据库批量自动备份(修改版)

数据库/ 2018-05-19/

  Mysql自动备份:
 
  建立要备份存放目录。如:D:/backup
 
  找到数据库文件所在目录的文件夹。如:D:/Program/MySQL5/data/
 
  在备份目录下,建立bd_bank_oleou.bat文件,输入

  单个数据库备份

net stop mysql(停止数据库 不复制)
 
xcopy D:/Program/MySQL5/data/mysql_name/*.* D:/backup/mysql_name_%date:~0,10%/ /y(将目录文件复制到备份目录,并以日期命名,不复制)

net start mysql(启动数据库 不复制)
 
c:/progra~1/winrar/winrar a  -k -r -s D:/backup/mysql_name_%date:~0,10%.rar D:/backup/mysql_name_%date:~0,10%(将刚刚复制过来的目录压缩。不复制)
 
rd D:/backup/mysql_name_%date:~0,10%/ /S /Q(删除刚刚的临时目录,保留了压缩文件 不复制) 内容来自oleou.com

  修改说明:
 
  1.解决mysql批量备份问题。如需备份多个数据库,分别添加3条想对应的命令即可。
 
  2.mysql数据库复制完成后即刻启动
 
  3.批量压缩并且删除复制过来的文件,避免重复和破坏,节约空间。
 
  4.此方法需要安装winrar
 
  批量备份:
net stop mysql
 
xcopy D:/Program/MySQL5/data/mysql_name/*.* D:/backup/mysql_name_%date:~0,10%/ /y
xcopy D:/Program/MySQL5/data/mysql_name1/*.* D:/backup/mysql_name1_%date:~0,10%/ /y
xcopy D:/Program/MySQL5/data/mysql_name2/*.* D:/backup/mysql_name2_%date:~0,10%/ /y

net start mysql
 
c:/progra~1/winrar/winrar a  -k -r -s D:/backup/mysql_name_%date:~0,10%.rar D:/backup/mysql_name_%date:~0,10% 内容来自oleou.com
c:/progra~1/winrar/winrar a  -k -r -s D:/backup/mysql_name1_%date:~0,10%.rar D:/backup/mysql_name1_%date:~0,10%
c:/progra~1/winrar/winrar a  -k -r -s D:/backup/mysql_name2_%date:~0,10%.rar D:/backup/mysql_name2_%date:~0,10%
 
rd D:/backup/mysql_name_%date:~0,10%/ /S /Q
rd D:/backup/mysql_name1_%date:~0,10%/ /S /Q
rd D:/backup/mysql_name2_%date:~0,10%/ /S /Q

  第三种方法【推荐】
net stop mysql
 
xcopy D:/Program/MySQL5/data/mysql_name/*.* D:/backup/backup_%date:~0,10%/mysql_name/ /y
xcopy D:/Program/MySQL5/data/mysql_name1/*.* D:/backup/backup_%date:~0,10%/mysql_name1/ /y
xcopy D:/Program/MySQL5/data/mysql_name2/*.* D:/backup/backup_%date:~0,10%/mysql_name2/ /y

net start mysql
 
c:/progra~1/winrar/winrar a  -k -r -s D:/backup/backup_%date:~0,10%.rar D:/backup/backup_%date:~0,10%

oleou.com

TAGS:

打赏 点赞
邮箱
验证码
昵称