YourSQLDba可以將數據庫備份到網絡路徑(共享路徑),這個也是非常靈活的一個功能,以前一直沒有使用過這個功能,最近由於一個需求,於是我測試了一下YourSQLDba備份到網絡路徑,中間遇到了一些問題,遂整理如下。
測試環境:
操作系統: Windows Server Standard 2012
數據庫版本: SQL SERVER 2014
1:設置共享路徑權限
這一步很簡單,也非常好理解。共享路徑需要給某些特定用戶才能訪問,例如某個域賬號。在此略過。
2:映射網絡驅動器。
映射網絡驅動器,顧名思義,就是將局域網內的一個共享文件夾作為一個虛擬的網絡硬盤,然後將該網絡硬盤映射到本地計算機,然後我們就可以在本地計算機上訪問該共享文件夾
3:然後使用Exec YourSQLDba.Maint.CreateNetworkDriv設置網絡路徑。
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.7.146\YourSQLDBABAK\Server1'
設置網絡路徑,必須開啟數據庫“xp_cmdshell”選項,否則就會有如下錯誤。
Exec YourSQLDba.Maint.CreateNetworkDrives
@DriveLetter = 'S:\'
@unc = '\\192.168.7.146\YourSQLDBABAK\Server1'
息 15123,級別 16,狀態 1,過程 sp_configure,第 62 行
he configuration option 'xp_cmdshell' does not exist, or it may be an advanced option.
et use S: /Delete
et use S: \\192.168.7.146\YourSQLDBABAK\Server1
5123: The configuration option 'xp_cmdshell' does not exist, or it may be an advanced option.
息 15123,級別 16,狀態 1,過程 sp_configure,第 62 行
he 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 =
'
'
在測試過程中發現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>