我有一個月度作業在我的SQL服務器上運行。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