您所在的位置:首页 > 资讯教程 > 新闻资讯 > sql备份的批处理

sql备份的批处理

2017-07-12 21:01:55  来源:互联网  次阅读

 @echo off

C:

CD "C:\Program Files\WinRAR"


net stop MySQL
winrar.exe a -ag"-[YYYY-MM-DD-HH-MM-SS]" -k -r -s -ibck -inul "G:\databak\mysql备份生成的文件.rar" "E:\Program Files\MySQL\MySQL Server 5.0\data\*.*"
net start Mysql

iisreset.exe

 

 

也可以:

net stop mysql 
xcopy c:\mysql\data\bbs\*.* d:\db_bak\bbs\%date:~0,10%\ /y 
net start mysql 

 

 

 

 

sql2008在作业中安排完整性和差异性备份的代码

 

1、完整性备份--ecol是数据库

declare @name varchar(250)
set @name='D:\dataBackup\ecol_backup_'+ 
convert(varchar(50),getdate(),112)+'.bak'
BACKUP DATABASE [ecol] TO  
DISK =@name  WITH NOFORMAT, NOINIT,  
NAME = N'ecol_backup_full', SKIP, REWIND, NOUNLOAD, COMPRESSION,  STATS = 10
Go

2、差异性备份

declare @name2 varchar(250)
set @name2='D:\dataBackup\ecology_backup_'+ 
convert(varchar(50),getdate(),112)+'0.bak'
BACKUP DATABASE [ecology] TO  
DISK = @name2 WITH  DIFFERENTIAL , NOFORMAT, NOINIT, 
NAME = N'ecology_backup_DIFFEREN', SKIP, REWIND, NOUNLOAD, COMPRESSION,  STATS = 10

 

3、事务备份

declare @name3 varchar(250)
set @name3='D:\dataBackup\ecology_backup_'+ 
convert(varchar(50),getdate(),112)+'.trn'
BACKUP LOG [ecology] TO  
DISK = @name3 WITH NOFORMAT, NOINIT,  
NAME = 'D:\dataBackup\ecology_backup_trn', SKIP, REWIND, NOUNLOAD, COMPRESSION,  STATS = 10

完整行备份 每周一次,差异性备份在完整性备份之外执行

大家都在看

回到顶部

下载声明 | 法律声明 | 版权声明 | 发布软件 | 解压密码 | 网站地图

本站所有软件,都由网友上传,如有侵犯你的版权,请发邮件给 8450500@qq.com