I had a great time speaking at the Kansas City SQL Server User Group on Thursday, February 18th. The more I present my Backup Basics with Powershell and dbatools session, the more I enjoy it. And each time, I’ve learned something new myself.
In one of the demos I show how
Restore-DbaDatabase selects and restores the most recent backup of a database when pointed at a directory holding several backups of a single database. Dan Maenle (twitter) asked how the function knows which one is the most recent. Timestamps? Filenames? Really good guesses? My takeaway from the session was to confirm the method in use.
Digging through a few layers of functions, the answer is: backup file headers. Which makes perfect sense, as it’s the most reliable method for this.
Read-DbaBackupHeader to examine each of the backup files. From there it determines which file(s) should be used to complete the restore. Terrific question from Dan, and now I’ve learned a bit more about these dbatools functions!
As a bonus, this session was recorded and it’ll be uploaded to the KC SQL Server User Group’s YouTube channel soon. The PowerPoint deck and the Azure Data Studio Notebook with the demos are available on my GitHub.
Thanks again to the User Group for giving me the opportunity to present, and for indulging my inner space geek as we anxiously awaited (and got confirmation of) the landing of Perseverance.