YourSQLDba设置共享路径备份

本文涉及的产品
云数据库 RDS SQL Server,独享型 2核4GB
简介:

 YourSQLDba可以将数据库备份到网络路径(共享路径),这个也是非常灵活的一个功能,以前一直没有使用过这个功能,最近由于一个需求,于是我测试了一下YourSQLDba备份到网络路径,中间遇到了一些问题,遂整理如下。

 

测试环境:

    操作系统:  Windows Server Standard 2012

  数据库版本:  SQL SERVER 2014

 

1:设置共享路径权限

 

    这一步很简单,也非常好理解。共享路径需要给某些特定用户才能访问,例如某个域账号。在此略过。

 

2:映射网络驱动器。

映射网络驱动器,顾名思义,就是将局域网内的一个共享文件夹作为一个虚拟的网络硬盘,然后将该网络硬盘映射到本地计算机,然后我们就可以在本地计算机上访问该共享文件夹

clipboard

clipboard[1]

 

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.

clipboard[2]

如果你遇到下面错误信息,请检查你SQL SERVER服务的登录账号是否是NT账号或域账号。如果是默认的NT Service\MSSQLSERVER则会遇到该错误提示。

clipboard[3]

clipboard[4]

可以讲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>
相关实践学习
使用SQL语句管理索引
本次实验主要介绍如何在RDS-SQLServer数据库中,使用SQL语句管理索引。
SQL Server on Linux入门教程
SQL Server数据库一直只提供Windows下的版本。2016年微软宣布推出可运行在Linux系统下的SQL Server数据库,该版本目前还是早期预览版本。本课程主要介绍SQLServer On Linux的基本知识。 相关的阿里云产品:云数据库RDS&nbsp;SQL Server版 RDS SQL Server不仅拥有高可用架构和任意时间点的数据恢复功能,强力支撑各种企业应用,同时也包含了微软的License费用,减少额外支出。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/sqlserver
相关文章
|
存储 数据安全/隐私保护 Windows
|
Oracle 关系型数据库 Perl
11gR2 GI和DB安装目录权限属主被修改后的恢复方法
     某位仁兄新装一套11gR2 RAC的过程中,在GI的安装配置阶段遇到了安装目录无法写入的报错,于是他便将$GRID_HOME下所有目录和文件属主改成了grid:oinstall,将$GRID_HOME下所有目录和文件权限改...
1009 0
|
Oracle 关系型数据库 数据库