sql备份的批处理

@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

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

你可能感兴趣的:(数据库)