Skip to content

Instantly share code, notes, and snippets.

@Stuart-Moore
Last active November 24, 2017 07:49
Show Gist options
  • Save Stuart-Moore/9a6bec3aa2710d719d58f2224491911a to your computer and use it in GitHub Desktop.
Save Stuart-Moore/9a6bec3aa2710d719d58f2224491911a to your computer and use it in GitHub Desktop.
$Backups = Get-DbaBackupInformation -sqlinstance localhost\sqlexpress2016 -Path C:\dbatools\RestoreTimeClean
$Backups += Get-DbaBackupInformation -sqlinstance localhost\sqlexpress2016 -Path C:\dbatools\RestoreTimeDiffStripe
$BackupSelection = $Backups | Select-DbaBackupInformation
$BackupSelection | Format-DbaBackupInformation
$basedir = "C:\some\path\of\yourchoosing\"
$BackupSelection | Foreach-Object {
ForEach ($file in $_.FileList){
$t = [system.io.FileInfo]$File.PhysicalName
$type = switch($file.Type){'D'{'Data'} 'L'{'Log'}}
$File.PhysicalName = [io.path]::combine($basedir,$_.Database+"_"+$type,$t.Name)
}
}
$BackupSelection | Test-DbaBackupInformation -SqlInstance localhost\developer2016
$BackupSelection | Invoke-DbaAdvancedRestore -sqlinstance localhost\developer2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment