sqlserver 2008 R2备份脚本

USE [master]
GO
/****** Object:  StoredProcedure [dbo].[fullbackup]    Script Date: 07/03/2013 07:29:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[fullbackup]
(
@backupPath varchar(500),
@databasename varchar(100),
@backuptype varchar(100)
)
as
DECLARE @FullPath varchar(1000)
set @FullPath = @backuppath+@databasename+'_'+@backuptype+'_'+replace(replace(replace(convert(varchar,getdate(),20),'-',''),' ',''),':','')+ '.bak'
backup database @databasename to disk=@FullPath
WITH buffercount = 20, maxtransfersize = 2097152 ,COMPRESSION,
RETAINDAYS=15,NOFORMAT,NOINIT,
NAME=N'完整备份',SKIP,NOREWIND,
NOUNLOAD,STATS=10
return
go
USE [master]
GO
/****** Object:  StoredProcedure [dbo].[diffBackup]    Script Date: 07/03/2013 07:30:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[diffBackup]
(
@backupPath varchar(500),
@databasename varchar(100),
@backuptype varchar(100)
)
as
DECLARE @FullPath varchar(1000)
set @FullPath = @backuppath+@databasename+'_'+@backuptype+'_'+replace(replace(replace(convert(varchar,getdate(),20),'-',''),' ',''),':','')+ '.diff'
backup database @databasename to disk=@FullPath
WITH buffercount = 30, maxtransfersize = 2097152 ,
COMPRESSION, DIFFERENTIAL,RETAINDAYS=8,NOFORMAT,NOINIT,
NAME=N'差异备份',SKIP,NOREWIND,
NOUNLOAD,STATS=10
return
go
USE [master]
GO
/****** Object:  StoredProcedure [dbo].[logBackup]    Script Date: 07/03/2013 07:30:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[logBackup]
(
@backupPath varchar(500),
@databasename varchar(100),
@backuptype varchar(100)
)
as
DECLARE @FullPath varchar(1000)
set @FullPath = @backuppath+@databasename+'_'+@backuptype+'_'+replace(replace(replace(convert(varchar,getdate(),20),'-',''),' ',''),':','')+ '.trn'
backup log @databasename to disk=@FullPath WITH RETAINDAYS=3,NOFORMAT,NOINIT,
NAME=N'日志备份',SKIP,NOREWIND,
NOUNLOAD,STATS=10
return
go
use master
go
exec master.dbo.fullbackup 'I:\backup\test\','test','full'
go
use master
go
exec master.dbo.diffbackup 'I:\backup\test\','test','diff'
go
use master
go
exec master.dbo.logbackup 'I:\backup\test\','test','log'
go


你可能感兴趣的:(sqlserver,2008,R2,备份脚本)