`

--ERP Database Network Backup

 
阅读更多

--ERP Database Network Backup
exec master..xp_cmdshell 'net use X: /delete /y'
exec master..xp_cmdshell 'net use X: \\192.168.1.188\myback  asdf;lkj1qaz /user:\ERP_backup' 

declare @NetPath  varchar(100)
declare @DBName   varchar(100)
declare @FileName varchar(100)

------------- DB_01 -------------------------------------------
set @NetPath='\\192.168.1.188\myback\'
set @DBName='DB_01'
set @FileName=@NetPath+@DBName+'_'+convert(varchar,getdate(),112)+'.bak'

exec master..sp_addumpdevice 'disk',@DBName,@FileName
backup database @DBName to @DBName with init,nounload,noskip,stats=10,noformat
exec master..sp_dropdevice @DBName

 --delete old backup
set @FileName='del '+@NetPath+@DBName+'_'+convert(varchar,getdate()-2,112)+'.bak'
exec master..xp_cmdshell @FileName

 

 

------------- SPC -------------------------------------------
set @NetPath='\\192.168.1.188\myback\'
set @DBName='SPC'
set @FileName=@NetPath+@DBName+'_'+convert(varchar,getdate(),112)+'.bak'

exec master..sp_addumpdevice 'disk',@DBName,@FileName
backup database @DBName to @DBName with init,nounload,noskip,stats=10,noformat
exec master..sp_dropdevice @DBName

 --delete old backup
set @FileName='del '+@NetPath+@DBName+'_'+convert(varchar,getdate()-2,112)+'.bak'
exec master..xp_cmdshell @FileName

 

------------- SunSystem -------------------------------------------
set @NetPath='\\192.168.1.188\myback\'
set @DBName='SunSystem'
set @FileName=@NetPath+@DBName+'_'+convert(varchar,getdate(),112)+'.bak'

exec master..sp_addumpdevice 'disk',@DBName,@FileName
backup database @DBName to @DBName with init,nounload,noskip,stats=10,noformat
exec master..sp_dropdevice @DBName

 --delete old backup
set @FileName='del '+@NetPath+@DBName+'_'+convert(varchar,getdate()-2,112)+'.bak'
exec master..xp_cmdshell @FileName

 

------------- OA -------------------------------------------
set @NetPath='\\192.168.1.188\myback\'
set @DBName='OA'
set @FileName=@NetPath+@DBName+'_'+convert(varchar,getdate(),112)+'.bak'

exec master..sp_addumpdevice 'disk',@DBName,@FileName
backup database @DBName to @DBName with init,nounload,noskip,stats=10,noformat
exec master..sp_dropdevice @DBName

 --delete old backup
set @FileName='del '+@NetPath+@DBName+'_'+convert(varchar,getdate()-2,112)+'.bak'
exec master..xp_cmdshell @FileName

 

 

 

 


------------- wsxPLM -------------------------------------------
set @NetPath='\\192.168.1.188\myback\'
set @DBName='wsxPLM'
set @FileName=@NetPath+@DBName+'_'+convert(varchar,getdate(),112)+'.bak'

exec master..sp_addumpdevice 'disk',@DBName,@FileName
backup database @DBName to @DBName with init,nounload,noskip,stats=10,noformat
exec master..sp_dropdevice @DBName

 --delete old backup
set @FileName='del '+@NetPath+@DBName+'_'+convert(varchar,getdate()-2,112)+'.bak'
exec master..xp_cmdshell @FileName


------------- DB_02 -------------------------------------------
set @NetPath='\\192.168.1.188\myback\'
set @DBName='DB_02'
set @FileName=@NetPath+@DBName+'_'+convert(varchar,getdate(),112)+'.bak'

exec master..sp_addumpdevice 'disk',@DBName,@FileName
backup database @DBName to @DBName with init,nounload,noskip,stats=10,noformat
exec master..sp_dropdevice @DBName

 --delete old backup
set @FileName='del '+@NetPath+@DBName+'_'+convert(varchar,getdate()-2,112)+'.bak'
exec master..xp_cmdshell @FileName


------------- DB_03 -------------------------------------------
set @NetPath='\\192.168.1.188\myback\'
set @DBName='DB_03'
set @FileName=@NetPath+@DBName+'_'+convert(varchar,getdate(),112)+'.bak'

exec master..sp_addumpdevice 'disk',@DBName,@FileName
backup database @DBName to @DBName with init,nounload,noskip,stats=10,noformat
exec master..sp_dropdevice @DBName

 --delete old backup
set @FileName='del '+@NetPath+@DBName+'_'+convert(varchar,getdate()-2,112)+'.bak'
exec master..xp_cmdshell @FileName

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics