0

I have a SQL VM in Azure that backs up to blob storage. I'd like a script that will give me the most recent restore time for each database backed up to that storage.

Get-DbaBackupInformation using the AzureCredential seems the obvious way to do it, but does anyone know the syntax for it? What should the -path parameter be?

I read this article

https://www.sqlservercentral.com/blogs/restoring-backups-from-azure-blob-with-dbatools

Which is fine but if I can just use the Get-DbaBackupInformation using the AzureCredential without having to enumerate the files with Get-AzStorageBlob first, that would be a more graceful solution.

Has anyone used this?

Cheers

Alex

1

1 Answer 1

0

The AzureCredential parameter is the name of a SQL Server Credential that has the Azure Credentials used for backing up/restoring backup files from Azure. This is the same credential you would use when performing a BACKUP TO URL.

For example, if you have a credential called

[https://<mystorageaccountname>.blob.core.windows.net/<mystorageaccountcontainername>]

then you would pass

-AzureCredential 'https://<mystorageaccountname>.blob.core.windows.net/<mystorageaccountcontainername>'

as the AzureCredential value to Get-DbaBackupInformation

Try using Get-DbaDbBackupHistory instead. This hits the backup tables in MSDB to fetch information about recent backups for any/all databases. This will be easier than reading the file headers if you only need recent backup info.

If you need to restore these files, you can pull the file information from Get-DbaDbBackupHistory to feed into Get-DbaBackupInformation (to produce as restore plan) or Restore-DbaDatabase (to restore directly).

2
  • Thanks for the reply. My use case if for a DR situation where the Geo replicated backups are available but the SQL server isn't. That's why I want to get the info straight from the file headers. I'll give it a go
    – AlexP012
    Commented Nov 29 at 7:34
  • "SqlInstance" is a required parameter of Get-DbaBackupInformation so even in your DR site, you will need a SQL Server available to read the header information from the files directly.
    – HandyD
    Commented Dec 2 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.