dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Performs various mapping on Backup History, ready restoring.
Options include changing restore paths, backup paths, database name and many others.




Changes as database name references to NewDb, both in the database name and any restore paths. Note, this will fail if the BackupHistory object contains backups for more than 1 database.

$History | Format-DbaBackupInformation -ReplaceDatabaseName NewDb

Will change all occurrences of original database name in the backup history (names and restore paths) using the mapping in the hashtable.
In this example any occurrence of OldDb will be replaced with NewDb and ProdHr with DevPR.

$History | Format-DbaBackupInformation -ReplaceDatabaseName @{‘OldB’=’NewDb’;’ProdHr’=’DevHr’}

This example with change the restore path for all data files (everything that is not a log file) to d:\datafiles.
And all Transaction Log files will be restored to E:\Logfiles.

$History | Format-DbaBackupInformation -DataFileDirectory ‘D:\DataFiles\’ -LogFileDirectory ‘E:\LogFiles\

This example changes the location that SQL Server will look for the backups. This is useful if you’ve moved the backups to a different location.

$History | Formate-DbaBackupInformation -RebaseBackupFolder f:\backups


This command was created by Stuart Moore. You can find Stuart on Twitter and his blog.


From PowerShell, execute Get-Help Format-DbaBackupInformation -Detailed for more information on this function.

Source Code

Want to see the source code? View Format-DbaBackupInformation.ps1 on GitHub

Related commands