利用SQL2000的DTS调度进行定期数据库备份

1.新建作业‘数据库备份’,如下图所示

image

2.在作业中新建‘步骤’,将下面的备份语句嵌入,并在‘调度’中设置合理的调度时间

image

image

3.备份语句

(1)本地备份

declare
@DW_Olap varchar(1000)

select @DW_Olap='D:/BACKUP/OLAP_BACKUP'++convert(varchar(2),datepart(weekday,getdate()))++'.bak'

---为节省空间,仅保留一周内的备份

backup database DW_Olap  to disk=@DW_Olap  WITH INIT

 

(2)跨服务器备份

declare
@dw_base_str varchar(1000),
@dw_clean_str varchar(1000),
@dw_olap_str varchar(1000),
@msdb_str varchar(1000),
@master_str varchar(1000)

exec master..xp_cmdshell 'net use //10.99.36.172/sqlbake /del'
exec master..xp_cmdshell 'net use //10.99.36.172/SqlBake sql_user2008 /user:lenged/sql_user'

select @dw_base_str='//10.99.36.172/sqlbake/dw_base/dw_base'++convert(varchar(2),datepart(weekday,getdate()))++'.bak'
select @dw_clean_str='//10.99.36.172/sqlbake/dw_clean/dw_clean'++convert(varchar(2),datepart(weekday,getdate()))++'.bak'
select @dw_olap_str='//10.99.36.172/sqlbake/dw_olap/dw_olap'++convert(varchar(2),datepart(weekday,getdate()))++'.bak'
select @msdb_str='//10.99.36.172/sqlbake/msdb/msdb'++convert(varchar(2),datepart(weekday,getdate()))++'.bak'
select @master_str='//10.99.36.172/sqlbake/master/master'++convert(varchar(2),datepart(weekday,getdate()))++'.bak'

---为节省空间,仅保留一周内的备份

backup database dw_base  to disk=@dw_base_str  WITH INIT
backup database dw_clean  to disk=@dw_clean_str WITH INIT
backup database dw_olap  to disk=@dw_olap_str WITH INIT
backup database msdb  to disk=@msdb_str WITH INIT
backup database master  to disk=@master_str WITH INIT

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值