YourSQLDba能夠將數據庫備份到網絡路徑(共享路徑),這個也是很是靈活的一個功能,之前一直沒有使用過這個功能,最近因爲一個需求,因而我測試了一下YourSQLDba備份到網絡路徑,中間遇到了一些問題,遂整理以下。 shell
測試環境: 數據庫
操做系統: Windows Server Standard 2012 網絡
數據庫版本: SQL SERVER 2014 app
1:設置共享路徑權限 測試
這一步很簡單,也很是好理解。共享路徑須要給某些特定用戶才能訪問,例如某個域帳號。在此略過。 spa
2:映射網絡驅動器。 操作系統
映射網絡驅動器,顧名思義,就是將局域網內的一個共享文件夾做爲一個虛擬的網絡硬盤,而後將該網絡硬盤映射到本地計算機,而後咱們就能夠在本地計算機上訪問該共享文件夾. YourSQLDba不能直接訪問共享路徑。不然會報錯。 code
3:而後使用Exec YourSQLDba.Maint.CreateNetworkDriv設置網絡路徑。orm
sp_configure 'show advanced option', 1;
go
reconfigure;
go
sp_configure 'xp_cmdshell', 1;
go
reconfigure;
go
Exec YourSQLDba.Maint.CreateNetworkDrives
@DriveLetter = 'S:\'
@unc = '\\192.168.xxx.xxx\YourSQLDBABAK\Server1'
設置網絡路徑,必須開啓數據庫「xp_cmdshell」選項,不然就會有以下錯誤。 blog
Exec YourSQLDba.Maint.CreateNetworkDrives
@DriveLetter = 'S:\'
, @unc = '\\192.168.xxx.xxx\YourSQLDBABAK\Server1'
消息 15123,級別 16,狀態 1,過程 sp_configure,第 62 行
The configuration option 'xp_cmdshell' does not exist, or it may be an advanced option.
net use S: /Delete
net use S: \\192.168.xxx.xxx\YourSQLDBABAK\Server1
15123: The configuration option 'xp_cmdshell' does not exist, or it may be an advanced option.
消息 15123,級別 16,狀態 1,過程 sp_configure,第 62 行
The configuration option 'xp_cmdshell' does not exist, or it may be an advanced option.
若是你遇到下面錯誤信息,請檢查你SQL SERVER服務的登陸帳號是不是NT帳號或域帳號。若是是默認的NT Service\MSSQLSERVER則會遇到該錯誤提示。
能夠將SQL Server服務的登陸帳號改成共享路徑設置權限的域帳號。那麼接下來,修改一下做業YourSQLDba_FullBackups_And_Maintenance裏面的配置信息就OK了
exec Maint.YourSqlDba_DoMaint
@oper = 'YourSQLDba_Operator'
, @MaintJobName = 'YourSQLDba: DoInteg,DoUpdateStats,DoReorg,Full backups'
, @DoInteg = 1
, @DoUpdStats = 1
, @DoReorg = 1
, @DoBackup = 'F'
, @FullBackupPath = 'S:\FULL_BACKUP\'
, @LogBackupPath = 'S:\LOG_BACKUP\'
-- Flush database backups older than the number of days
, @FullBkpRetDays = 1
-- Flush log backups older than the number of days
, @LogBkpRetDays =1
-- Spread Update Stats over 7 days
, @SpreadUpdStatRun =1
-- Maximum number of consecutive days of failed full backups allowed
-- for a database before putting that database (Offline).
, @ConsecutiveFailedbackupsDaysToPutDbOffline = 9999
-- Each database inclusion filter must be on its own line between the following quote pair
, @IncDb =
'
'
-- Each database exclusion filter must be on its own line between the following quote pair
, @ExcDb =
'
'
-- Each database exclusion filter must be on its own line between the following quote pair
, @ExcDbFromPolicy_CheckFullRecoveryModel =
'
'
若是SQL Server服務是LocalSystem啓動,YourSQLDba備份時會報以下錯誤信息,你須要將SQL Server服務的登陸身份改成域帳號
BackupDiskFile::CreateMedia: 備份設備 'S:\FULL_BACKUP\MsDb_[2016-07-04_Mon]_database.BAK' 沒法create。操做系統錯誤 5(拒絕訪問。)。
在測試過程當中發現YourSQLDba備份到共享路徑對網絡環境要求比較高,有幾回在網絡出現連續掉兩個或兩個以上包的時候,備份進程就出錯,檢查出錯信息,發現以下錯誤信息。
<Exec>
<ctx>yMaint.backups</ctx>
<Sql>
backup database [WSS_Content_get_teams_tdc]
to disk = 'S:\FULL_BACKUP\Test_[2014-11-11_18h49m05_Tue]_database.BAK'
with Init, Format, checksum, name = 'YourSQLDba:18h49: S:\FULL_BACKUP\Test_[2014-11-11_18h49m05_Tue]_database.BAK'
</Sql>
<err>Error 3201, Severity 16, level 1 : Cannot open backup device 'S:\FULL_BACKUP\Test_[2014-11-11_18h49m05_Tue]_database.BAK'. Operating system error 53(The network path was not found.).
Error 3013, Severity 16, level 1 : BACKUP DATABASE is terminating abnormally.
</err>
</Exec>