Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test-DbaLastBackup doesn't execute if backup file is corrupted. #4957

Closed
githubsqltoolsse opened this issue Jan 15, 2019 · 1 comment · Fixed by #5249
Closed

Test-DbaLastBackup doesn't execute if backup file is corrupted. #4957

githubsqltoolsse opened this issue Jan 15, 2019 · 1 comment · Fixed by #5249

Comments

@githubsqltoolsse
Copy link
Contributor

Before submitting a bug report:

  • [ x] Ensure you are able to reproduce it on the latest released version (we release often)
  • [x ] Verified this bug is not already reported in an issue
  • [ x] Verified errors are not related to permissions
  • [ x] Can reproduce in a clean PowerShell session (clean = powershell -NoProfile)

Steps to Reproduce

If I run this command when one log file is corrupt.
Test-DbaLastBackup -SqlInstance MySourceServer -Destination MyTestServer\RESTORETEST -DataDirectory "E:\SqlData\RestoreTest" -LogDirectory "F:\SqlLog\RestoreTest" -Database MyDatabase

Expected Behavior

I expect a return from the command simmilar to this:
SourceServer : MySourceServer
TestServer : MyTestServer\RESTORETEST
Database : MyDatabase
FileExists : True
Size : 2,08 GB
RestoreResult : Failure
DbccResult : Skipped
RestoreStart : 2019-01-15 15:47:05.139
RestoreEnd : 2019-01-15 15:47:05.957
RestoreElapsed : 00:00:00
DbccStart :
DbccEnd :
DbccElapsed :
BackupDates : {01/14/2019 16:00:48, 01/15/2019 15:29:42, 01/15/2019 15:29:52, 01/15/2019 15:30:00...}
BackupFiles : {List of files...}

I also expect that the test removes the restored database.

Actual Behavior

I got several objects similar to this one. this is the last object with Restore Complete false:

ComputerName : MyTestServer
InstanceName : RESTORETEST
SqlInstance : MyTestServer\RESTORETEST
BackupFile : \MySourceServer\SQLBackup\MySourceServer\MyDatabase\LOG\MySourceServer_MyDatabase_LOG_20190115_153500
.trn
BackupFilesCount : 1
BackupSize : 75,00 KB
CompressedBackupSize : 4,42 KB
Database : dbatools-testrestore-MyDatabase
Owner : MyAD\sepdba_da
DatabaseRestoreTime : 00:00:13
FileRestoreTime : 00:00:00
NoRecovery : True
RestoreComplete : False
RestoredFile : dbatools-testrestore-MyDatabase.mdf,dbatools-testrestore-MyDatabase_log.ldf
RestoredFilesCount : 2
Script : {RESTORE LOG [dbatools-testrestore-MyDatabase] FROM DISK = N'\MySourceServer\SQLBackup\SESTODS0
21\MyDatabase\LOG\MySourceServer_MyDatabase_LOG_20190115_153500.trn' WITH FILE = 1, MOVE N'T
raveExpense' TO N'E:\SqlData\RestoreTest\dbatools-testrestore-MyDatabase.mdf', MOVE N'TraveE
xpense_log' TO N'F:\SqlLog\RestoreTest\dbatools-testrestore-MyDatabase_log.ldf', NORECOVERY,
NOUNLOAD, STATS = 10}
RestoreDirectory : E:\SqlData\RestoreTest,F:\SqlLog\RestoreTest
WithReplace : False

The restored database is left at the testserver.

I also got this warning:

WARNING: [15:24:10][Restore-DbaDatabase] Failure | System.Data.SqlClient.SqlError: The media family on device '\MySourceServer\SQLBackup\MySourceServer\MyDatabase\LOG\MySourceServer_MyDatabase_LOG_20190114_135501.trn' is incorrectly formed. SQL Server cannot process this media
family.

laste error code is:
$error[0] | select *

writeErrorStream : True
PSMessageDetails :
Exception : System.Exception: System.Data.SqlClient.SqlError: The media family on device '\MySourceServer\SQLB
ackup\MySourceServer\MyDatabase\LOG\MySourceServer_MyDatabase_LOG_20190115_153500.trn' is incorre
ctly formed. SQL Server cannot process this media family. ---> System.Exception: System.Data.Sq
lClient.SqlError: The media family on device '\MySourceServer\SQLBackup\MySourceServer\MyDatabase\L
OG\MySourceServer_MyDatabase_LOG_20190115_153500.trn' is incorrectly formed. SQL Server cannot p
rocess this media family. ---> System.Management.Automation.MethodInvocationException: Exceptio
n calling "SqlRestore" with "1" argument(s): "Restore failed for Server 'MyTestServer\RESTORETEST
'. " ---> Microsoft.SqlServer.Management.Smo.FailedOperationException: Restore failed for Serve
r 'MyTestServer\RESTORETEST'. ---> Microsoft.SqlServer.Management.Smo.SmoException: System.Data.
SqlClient.SqlError: The media family on device '\MySourceServer\SQLBackup\MySourceServer\MyDatabase
\LOG\MySourceServer_MyDatabase_LOG_20190115_153500.trn' is incorrectly formed. SQL Server cannot
process this media family.
vid Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQueryWithMessage(StringCol
lection queries, ServerMessageEventHandler dbccMessageHandler, Boolean errorsAsMessages, Boolea
n retry)
vid Microsoft.SqlServer.Management.Smo.BackupRestoreBase.ExecuteSql(Server server, StringCol
lection queries)
vid Microsoft.SqlServer.Management.Smo.Restore.SqlRestore(Server srv)
--- Slut på stackspårning för interna undantag ---
vid Microsoft.SqlServer.Management.Smo.Restore.SqlRestore(Server srv)
vid CallSite.Target(Closure , CallSite , Object , Object )
--- Slut på stackspårning för interna undantag ---
vid System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
funcContext, Exception exception)
vid System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame fr
ame)
vid System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(Interpreted
Frame frame)
vid System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(Interpreted
Frame frame)
--- Slut på stackspårning för interna undantag ---
--- Slut på stackspårning för interna undantag ---
TargetObject : MyTestServer\RESTORETEST
CategoryInfo : NotSpecified: (MyTestServer\RESTORETEST:PSObject) [Write-Error], Exception
FullyQualifiedErrorId : dbatools_Restore-DbaDatabase,Stop-Function
ErrorDetails : System.Data.SqlClient.SqlError: The media family on device '\MySourceServer\SQLBackup\MySourceServer\T
ravelExpense\LOG\MySourceServer_MyDatabase_LOG_20190115_153500.trn' is incorrectly formed. SQL S
erver cannot process this media family.
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at Stop-Function, : line 104438
at Restore-DbaDatabase, : line 82166
at Test-DbaLastBackup, : line 98296
at , : line 1
PipelineIterationInfo : {0, 1}

Environmental data

  • PowerShell:
    Name Value

PSVersion 5.1.17134.407
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.407
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

    • SQL Server:
      Test server:
      Microsoft SQL Server 2017 (RTM-CU12) (KB4464082) - 14.0.3045.24 (X64) Oct 18 2018 23:11:05 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2012 Datacenter 6.2 (Build 9200: ) (Hypervisor)
      Source server:
      Microsoft SQL Server 2016 (SP2-CU1) (KB4135048) - 13.0.5149.0 (X64) May 19 2018 09:41:57 Copyright (c) Microsoft Corporation Developer Edition (64-bit) on Windows Server 2012 R2 Datacenter 6.3 (Build 9600: ) (Hypervisor)
@stale stale bot added stale Stale Bot label used to identify issues that are no longer active and bot has closed them and removed stale Stale Bot label used to identify issues that are no longer active and bot has closed them labels Mar 16, 2019
@dataplat dataplat deleted a comment from stale bot Mar 19, 2019
@potatoqualitee
Copy link
Member

thanks for the report, can repro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants