Verify backup files before restore in another server #9650
Unanswered
DanielEriksson-Avega
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I have a case where I take backups (full + transactions) from an on-prem database, these backups are copied to a storage account in azure. I am using these backups to refresh a test database to point in time in another location. But sometimes backups are not properly copied and the restore will not be done.
I want to verify the backup files before even stop the test application and trying to restore the database.
fyi: I cant read the backup history from the source system, only the backup file in the storage account.
I have been trying to use a combination of the commands and got something like below.
Is this the way to do it or is there any other/more effective way of verifying the files before executing the restore command?
$blobs = Get-AzStorageBlob -Context $context -Container 'mycontainer'
$filteredblobs = ($blobs).ICloudBlob.Uri.AbsoluteUri
$backups = Get-DbaBackupInformation -SqlInstance 'mytestserver' -Path $filteredblobs -AzureCredential AzureCredentials -DirectoryRecurse
$FilteredBackups = $backups | Select-DbaBackupInformation -RestoreTime $pointintime -DatabaseName 'mysourcedb'
$formattedbackups = $FilteredBackups | Format-DbaBackupInformation -ReplaceDatabaseName 'mytargetdb'
$formattedbackups | Test-DbaBackupInformation -SqlInstance 'mytestserver' -WithReplace
$PassedDbs = $formattedbackups | Where-Object {$_.IsVerified -eq $True}
if($PassedDbs)
{
Write-Output 'Backup is okay'
#restore-DbaDatabase
}
Beta Was this translation helpful? Give feedback.
All reactions