2023年6月16日 星期五

[SQL SERVER] 設定排程備份至網路磁碟

 利用排程精靈,開啟CmdShell先掛載網路磁碟,執行備份後再移除網路磁碟。


1. 執行T-SQL,掛載網路磁碟

EXEC sp_configure 'show advanced options', 1

GO

-- To update the currently configured value for advanced options.

RECONFIGURE

GO

-- To enable the feature.

EXEC sp_configure 'xp_cmdshell', 1

GO

-- To update the currently configured value for this feature.

RECONFIGURE

GO

 

exec master..xp_cmdshell 'net use V: \\127.0.0.1/MyFolder /user:[User] [Password]'




2. 設定備份



3. 設定清除工作



4. 執行T-SQL,移除網路磁碟

exec master..xp_cmdshell 'net use V: /delete'

 

 

 

EXEC sp_configure 'show advanced options', 1

GO

-- To update the currently configured value for advanced options.

RECONFIGURE

GO

-- To disable the feature.

EXEC sp_configure 'xp_cmdshell', 0

GO

-- To update the currently configured value for this feature.

RECONFIGURE

GO

 









沒有留言:

張貼留言