SQL服务器的完全备份作业跳过数据库(SQL server Full backup job is s

2019-11-02 13:55发布

我有我的SQL服务器上运行的月度职位。

  • 它备份所有的在线数据库的位置“\ BackupServer的\ E $ \ MonthEndBackups \”。

  • 作业运行下面的USP这样:EXEC [usp_dba_BackupDatabases] 3( http://screencast.com/t/l7IS5TZK )

  • 它运行在该月的最后一天。

我们的数据库进行了散落在多个服务器和这项工作在这些服务器上运行,这用来工作。

我们巩固了在同一台服务器(同一个SQL实例)所有的数据库,这工作似乎并没有备份所有的数据库没有。 我不知道为什么? 我的工作对故障通知(电子邮件),并写入日志文件。

http://screencast.com/t/8ioTZdqEMg9x http://screencast.com/t/VI3d4GLBTGoX

但没有失败,所以没有什么是对日志和没有电子邮件通知显示。

我知道,因为我没有看到该文件夹​​的完整备份它没有工作。

这里是计划设置:

http://screencast.com/t/waeGwLSa

可能是什么回事? 我看不出在没有备份数据库的任何图案。 有迹象表明,越来越备份的大型数据库。

谁能想到这可能是为什么发生? 有没有什么办法麻烦拍摄这个?

USE [DBA]
GO

/****** Object:  StoredProcedure [dbo].[usp_dba_BackupDatabases]    Script Date: 10/01/2013 11:10:26 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[usp_dba_BackupDatabases] 
    @pBackupType        SMALLINT
    ,@pDatabaseName     sysname = NULL

AS



SET NOCOUNT ON


DECLARE @vDatabase sysname, @sql VARCHAR(MAX), @vBackupFileFullPath VARCHAR(MAX)

DECLARE c CURSOR FOR 
SELECT  name FROM sys.sysdatabases
WHERE name NOT IN('tempdb', 'model')
    AND DATABASEPROPERTYEX (name,'STATUS') IN( 'ONLINE')
    AND (name  = @pDatabaseName OR @pDatabaseName IS NULL)

OPEN c
FETCH NEXT FROM c INTO @vDatabase
WHILE @@FETCH_STATUS = 0 
BEGIN

SELECT CONVERT(VARCHAR,GETDATE(),121)
    PRINT '|-->' + CONVERT(VARCHAR,GETDATE(),121) +' Backup Start for database ' + @vDatabase 

    IF @pBackupType = 1
        BEGIN
            SET @vBackupFileFullPath = '\\Backupserver\d$\' + @@SERVERNAME +'\' + @vDatabase +'_DB_'
                +REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(16),GETDATE(),112),'-',''),' ',''),':','') +'.bak'
            SET @sql  = 'BACKUP DATABASE ' + @vDatabase + ' TO  DISK = N' + CHAR(39) + @vBackupFileFullPath +  char(39) 
            + ' WITH FORMAT, INIT,  NAME = N' + CHAR(39) + @vDatabase + ' -Full Database Backup' + CHAR(39) + ', SKIP, NOREWIND, NOUNLOAD,  STATS = 5, CHECKSUM'
        END


    IF @pBackupType = 2
        BEGIN
            SET @vBackupFileFullPath = '\\Backupserver\d$\' + @@SERVERNAME + '\Differential\' + @vDatabase +'_Diff_'
                 +REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(16),GETDATE(),121),'-',''),' ',''),':','') +'.bak'        
            SET @sql  = 'BACKUP DATABASE ' + @vDatabase + ' TO  DISK = N' + CHAR(39) +  @vBackupFileFullPath + char(39)
                 + ' WITH DIFFERENTIAL , FORMAT, INIT, NAME = N' + CHAR(39) + @vDatabase 
                                + ' -Differential Database Backup' + CHAR(39) + ', SKIP, NOREWIND, NOUNLOAD,  STATS = 5, CHECKSUM'              
        END

    IF @pBackupType = 3
        BEGIN
            SET @vBackupFileFullPath = '\\Backupserver\e$\MonthEndBackups\' + @@SERVERNAME +'_'+ @vDatabase +'_db.bak'
            SET @sql  = 'BACKUP DATABASE ' + @vDatabase + ' TO  DISK = N' + CHAR(39) + @vBackupFileFullPath  + char(39) 
                + ' WITH COPY_ONLY, FORMAT, INIT,  NAME = N' + CHAR(39) + @vDatabase + ' -Full Month End Database Backup' + CHAR(39) + ', SKIP, NOREWIND, NOUNLOAD,  STATS = 5, CHECKSUM'           
        END

    PRINT ' |'+ @sql  
    EXEC (@sql )


    --VERIFY BACKUP

    IF @pBackupType = 1
        SET @sql  = 'RESTORE VERIFYONLY FROM DISK = N' + CHAR(39) + @vBackupFileFullPath +  char(39) 
                    + ' WITH  FILE = 1,  NOUNLOAD,  NOREWIND'

    IF @pBackupType = 2
        SET @sql  = 'RESTORE VERIFYONLY FROM DISK = N' + CHAR(39) + @vBackupFileFullPath + char(39)
                 + ' WITH  FILE = 1,  NOUNLOAD,  NOREWIND'

    IF @pBackupType = 3
        SET @sql  = 'RESTORE VERIFYONLY FROM DISK = N' + CHAR(39) + @vBackupFileFullPath + char(39) 
                    + ' WITH  FILE = 1,  NOUNLOAD,  NOREWIND'

    --PRINT '   |'+ @sql  
    --EXEC (@sql )



    PRINT '|-->' + CONVERT(VARCHAR,GETDATE(),121) +' Backup Complete for database ' + @vDatabase 
    PRINT '' 

    FETCH NEXT FROM c INTO @vDatabase
END

CLOSE c
DEALLOCATE c



GO

Answer 1:

尝试使用下面的选项(固定有可能打破当前的环路和选项也打破sp_MSforeachdb ,因为我已经证明在这里和这里 ,并在这里纠正 ):

DECLARE c CURSOR LOCAL FAST_FORWARD FOR
-----------------^^^^^^^^^^^^^^^^^^

...

WHILE @@FETCH_STATUS <> -1
---------------------^^^^^

另外, 请,请,请停止宣告VARCHAR不长 。



文章来源: SQL server Full backup job is skipping databases