< Back

Read-DbaBackupHeader

Mon Jan 13, 2020 1:05 pm

NAME Read-DbaBackupHeader



SYNOPSIS

Reads and displays detailed information about a SQL Server backup.





SYNTAX

Read-DbaBackupHeader [-SqlInstance] <DbaInstanceParameter> [[-SqlCredential] <Pscredential>] [-Path]

<System.Object[]> [-Simple <Switch>] [-FileList <Switch>] [[-AzureCredential] <String>] [-EnableException

<Switch>] [<CommonParameters>]





DESCRIPTION

Reads full, differential and transaction log backups. An online SQL Server is required to parse the backup files

and the path specified must be relative to that SQL Server.





PARAMETERS

-AzureCredential [<String>]

Name of the SQL Server credential that should be used for Azure storage access.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning

message. This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically

disables advanced scripting.

Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own

try/catch.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-FileList [<Switch>]

If this switch is enabled, detailed information about the files within the backup is returned.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Path [<System.Object[]>]

Path to SQL Server backup file. This can be a full, differential or log backup file. Accepts valid filesystem

paths and URLs.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Simple [<Switch>]

If this switch is enabled, fewer columns are returned, giving an easy overview.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlCredential [<Pscredential>]

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).



Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -

Integrated are all supported.



For MFA support, please use Connect-DbaInstance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<DbaInstanceParameter>]

The target SQL Server instance or instances.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: DisasterRecovery, Backup, Restore

Author: Chrissy LeMaire (@cl), netnerds.net



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Read-DbaBackupHeader -SqlInstance sql2016 -Path S:\\backups\\mydb\\mydb.bak



Logs into sql2016 using Windows authentication and reads the local file on sql2016, S:\\backups\\mydb\\mydb.bak.



If you are running this command on a workstation and connecting remotely, remember that sql2016 cannot access

files on your own workstation.

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Read-DbaBackupHeader -SqlInstance sql2016 -Path \\\\nas\\sql\\backups\\mydb\\mydb.bak,

\\\\nas\\sql\\backups\\otherdb\\otherdb.bak



Logs into sql2016 and reads two backup files - mydb.bak and otherdb.bak. The SQL Server service account must have

rights to read this file.

-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Read-DbaBackupHeader -SqlInstance . -Path C:\\temp\\myfile.bak -Simple



Logs into the local workstation (or computer) and shows simplified output about C:\\temp\\myfile.bak. The SQL Server

service account must have rights to read this file.

-------------------------- EXAMPLE 4 --------------------------



PS C:\\>$backupinfo = Read-DbaBackupHeader -SqlInstance . -Path C:\\temp\\myfile.bak



PS C:\\> $backupinfo.FileList



Displays detailed information about each of the datafiles contained in the backupset.

-------------------------- EXAMPLE 5 --------------------------



PS C:\\>Read-DbaBackupHeader -SqlInstance . -Path C:\\temp\\myfile.bak -FileList



Also returns detailed information about each of the datafiles contained in the backupset.

-------------------------- EXAMPLE 6 --------------------------



PS C:\\>"C:\\temp\\myfile.bak", "\\backupserver\\backups\\myotherfile.bak" | Read-DbaBackupHeader -SqlInstance sql2016

| Where-Object { $_.BackupSize.Megabyte -gt 100 }



Reads the two files and returns only backups larger than 100 MB

-------------------------- EXAMPLE 7 --------------------------



PS C:\\>Get-ChildItem \\\\nas\\sql\\*.bak | Read-DbaBackupHeader -SqlInstance sql2016



Gets a list of all .bak files on the \\\\nas\\sql share and reads the headers using the server named "sql2016". This

means that the server, sql2016, must have read access to the \\\\nas\\sql share.

-------------------------- EXAMPLE 8 --------------------------



PS C:\\>Read-DbaBackupHeader -SqlInstance sql2016 -Path

https://dbatoolsaz.blob.core.windows.ne ... 131850.bak -AzureCredential

AzureBackupUser



Gets the backup header information from the SQL Server backup file stored at

https://dbatoolsaz.blob.core.windows.ne ... 131850.bak on Azure



RELATED LINKS

https://dbatools.io/Read-DbaBackupHeader