June 9, 2010 at 2:15 pm
I'm trying to restore a SQL Server 2005 database to a SQL Server 2008 server with the following script but I am getting an error which states:
Restoring CDR_Main_Dev (database) from:
E:\SQLBackups\CDR_Main_Dev\CDR_Main_FULL_20100609_000003_04.sqb
E:\SQLBackups\CDR_Main_Dev\CDR_Main_FULL_20100609_000003_05.sqb
E:\SQLBackups\CDR_Main_Dev\CDR_Main_FULL_20100609_000003_03.sqb
E:\SQLBackups\CDR_Main_Dev\CDR_Main_FULL_20100609_000003_01.sqb
E:\SQLBackups\CDR_Main_Dev\CDR_Main_FULL_20100609_000003_02.sqb
Thread 0 error:
Failed to service command. Error code: -2139684860
Process terminated unexpectedly. Error code: -2139684860 (An abort request is preventing anything except termination actions.)
Thread 1 error:
Failed to service command. Error code: -2139684860
Process terminated unexpectedly. Error code: -2139684860 (An abort request is preventing anything except termination actions.)
Thread 2 error:
Process terminated unexpectedly. Error code: -2139684860 (An abort request is preventing anything except termination actions.)
Thread 3 error:
Process terminated unexpectedly. Error code: -2139684860 (An abort request is preventing anything except termination actions.)
Thread 4 error:
Process terminated unexpectedly. Error code: -2139684860 (An abort request is preventing anything except termination actions.)
SQL error 3013: SQL error 3013: RESTORE DATABASE is terminating abnormally.
SQL error 3241: SQL error 3241: The media family on device 'SQLBACKUP_273C82FD-3412-49B2-9669-42A275B6845802' is incorrectly formed. SQL Server cannot process this media family.
SQL error 3203: SQL error 3203: Read on "SQLBACKUP_273C82FD-3412-49B2-9669-42A275B68458" failed: 995(The I/O operation has been aborted because of either a thread exit or an application request.)
SQL Backup exit code: 790
SQL error code: 3203
use master
go
SET NOCOUNT ON
declare @optstring varchar(4000)
declare @targetDB varchar(100)
declare @dt varchar(8)
declare @ix varchar(6)
declare @KILL_EXISTING_CONNS varchar(5)
select @dt = CONVERT(varchar, getdate(), 112)
-----------------------------------------------------------
-- SET THESE FIRST
-----------------------------------------------------------
SET @KILL_EXISTING_CONNS = 'TRUE'
--SET @KILL_EXISTING_CONNS = 'FALSE'
SET @targetDB = 'CDR_Main_Dev'
--SET @targetDB = 'CDR_Main_Test'
SET @ix = '000003'
--SET @ix = '000001'
IF COALESCE(@targetDB, '') = ''
BEGIN
RAISERROR('SPECIFY THE TARGET DATABASE', 0, 1) WITH NOWAIT
RETURN
END
-----------------------------------------------------------
-- Check if one of the files exists using default filename.
-- Abort if it does not, the sqlbackup command takes 25 mins
-- to run only to tell you that the files do not exist.
-----------------------------------------------------------
DECLARE @file VARCHAR(255)
DECLARE @status bit
DECLARE @CopyCmd as varchar(4000)
SET @file = '\\MedCDR\f$\SQLBackups\CDR_Main\CDR_Main_FULL_' + @dt + '_' + @ix + '_01.sqb'
SET @status = 0
Declare @FileCheck Table (
FileName varchar(200)
)
DECLARE @FileExists TABLE(isFile bit, isDir bit, hasParentDir bit)
INSERT INTO @FileExists exec master.dbo.xp_fileexist @file
SELECT @status = isFile FROM @FileExists
IF @status = 1
BEGIN
--Set @CopyCmd = 'xcopy \\MedCDR\f$\SQLBackups\CDR_Main\CDR_Main_FULL_' + @dt + '_' + @ix + '_01.sqb E:\SQLBackups\CDR_Main_Dev /r /y'
--Insert Into @FileCheck Exec xp_cmdshell @CopyCmd
--Set @CopyCmd = 'xcopy \\MedCDR\f$\SQLBackups\CDR_Main\CDR_Main_FULL_' + @dt + '_' + @ix + '_02.sqb E:\SQLBackups\CDR_Main_Dev /r /y'
--Insert Into @FileCheck Exec xp_cmdshell @CopyCmd
--Set @CopyCmd = 'xcopy \\MedCDR\f$\SQLBackups\CDR_Main\CDR_Main_FULL_' + @dt + '_' + @ix + '_03.sqb E:\SQLBackups\CDR_Main_Dev /r /y'
--Insert Into @FileCheck Exec xp_cmdshell @CopyCmd
--Set @CopyCmd = 'xcopy \\MedCDR\f$\SQLBackups\CDR_Main\CDR_Main_FULL_' + @dt + '_' + @ix + '_04.sqb E:\SQLBackups\CDR_Main_Dev /r /y'
--Insert Into @FileCheck Exec xp_cmdshell @CopyCmd
--Set @CopyCmd = 'xcopy \\MedCDR\f$\SQLBackups\CDR_Main\CDR_Main_FULL_' + @dt + '_' + @ix + '_05.sqb E:\SQLBackups\CDR_Main_Dev /r /y'
--Insert Into @FileCheck Exec xp_cmdshell @CopyCmd
set @optstring = '-SQL "RESTORE DATABASE [' + @targetDB +']
FROM DISK = ''E:\SQLBackups\CDR_Main_Dev\CDR_Main_FULL_' + @dt + '_' + @ix + '_04.sqb'',
DISK = ''E:\SQLBackups\CDR_Main_Dev\CDR_Main_FULL_' + @dt + '_' + @ix + '_05.sqb'',
DISK = ''E:\SQLBackups\CDR_Main_Dev\CDR_Main_FULL_' + @dt + '_' + @ix + '_03.sqb'',
DISK = ''E:\SQLBackups\CDR_Main_Dev\CDR_Main_FULL_' + @dt + '_' + @ix + '_01.sqb'',
DISK = ''E:\SQLBackups\CDR_Main_Dev\CDR_Main_FULL_' + @dt + '_' + @ix + '_02.sqb'' WITH RECOVERY,
DISCONNECT_EXISTING,
MOVE ''CDR_Main_Dev'' TO ''E:\Data\Databases\' + @targetDB +'.mdf'',
MOVE ''CDR_Main_Dev_log'' TO ''E:\Data\Databases\' + @targetDB +'_log.ldf'',
REPLACE,
ORPHAN_CHECK"'
BEGIN TRY
--RAISERROR(@optstring, 0, 1) WITH nowait
--print @optstring
EXECUTE sqlbackup @optstring
END TRY
BEGIN CATCH
DECLARE@ErrorMessage NVARCHAR(4000),
@ErrorNumber INT,
@ErrorSeverity INT,
@ErrorState INT
SELECT@ErrorMessage = Error_Message(),
@ErrorNumber = Error_Number(),
@ErrorSeverity = Error_Severity(),
@ErrorState = Error_State()
SET @ErrorMessage = REPLACE('ERROR trying to restore: @@err', '@@err', @ErrorMessage)
RAISERROR(@ErrorMessage,@ErrorSeverity, @ErrorState)
END CATCH
END
ELSE
BEGIN
DECLARE @Msg VARCHAR(300)
SET @Msg = @file + ' does not exist, try changing ' + @ix + ' to another value'
RAISERROR(@Msg, 0, 1) WITH NOWAIT
END
GO
[\code]
June 9, 2010 at 3:02 pm
What 3rd party backup tool are you using?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 9, 2010 at 3:05 pm
Sure sounds like something is broken in the backup file:
SQL error 3241: SQL error 3241: The media family on device 'SQLBACKUP_273C82FD-3412-49B2-9669-42A275B6845802' is incorrectly formed. SQL Server cannot process this media family.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply