sql2005数据库备份脚本(完全备份到指定位置,差异备份到指定位置)
完全备份declare @device varchar(255),@path varchar(255),@dbname varchar(255)set @dbname='MIS_TEMP'set @path='D:\project\eosserver\MIS_TEMP\Data\Backup\'set @device=@path+@dbname+'_COMP_'+ convert(char(8),getdate(),112)+replace(convert(char(9),getdate(),114),':','')+'.bak'BACKUP DATABASE @dbname TO DISK = @device with init---完全备份,覆盖原有文件---BACKUP DATABASE @dbname TO DISK = @device with init---完全备份,在原有文件后面追加---BACKUP DATABASE @dbname TO DISK = @device ---差异备份---BACKUP DATABASE @dbname TO DISK = @device WITH DIFFERENTIAL差异备份declare @device varchar(255),@path varchar(255),@dbname varchar(255)set @dbname='MIS_TEMP'set @path='D:\project\eosserver\MIS_TEMP\Data\Backup\'set @device=@path+@dbname+'_DIFF_'+ convert(char(8),getdate(),112)+replace(convert(char(9),getdate(),114),':','')+'.bak'BACKUP DATABASE @dbname TO DISK = @device WITH DIFFERENTIAL---完全备份,覆盖原有文件BACKUP DATABASE @dbname TO DISK = @device with init---完全备份,在原有文件后面追加BACKUP DATABASE @dbname TO DISK = @device ----差异备份BACKUP DATABASE @dbname TO DISK = @device WITH DIFFERENTIAL