Restoring a database with DBATools and Restore-DBADatabase

Hi all,

I’m using Restore-DBADatabase in DBATools to restore a daily database. Here’s the scenario. Vendor delivers a full backup of the database on Sundays and I download to D:\Bacups and restore it to our local database overwriting with:

Restore-DBADatabase -SQLInstance $Instance -Path D:\Backups -WithReplace

The rest of the week the vendor delivers differential files. So, for example, when I download Mondays differential to D:\Backups the full and the new diff are in the folder. Do I need to use the -WithReplace option, or is Restore-DBADatabase smart enough to figure out to just restore the differential file since the full backup was restored the day before? So, can I just do:

Restore-DBADatabase -SQLInstance $Instance -Path D:\Backups

Or do I need to remove the full backup file from the folder before restoring the differential so it doesn’t restore the whole database again?

I’m not really a DBA, so coming at this from powershell and DBATools.



I was hoping someone with more experience than I respond :smiley: but… my first though honestly is… why not just test it and see how it behaves in both scenarios? Can you spin up another DB and just run the commands and inspect the data before and after? Lots of folks here aren’t DBAs either so probably why you haven’t got a response, sorry about that.

It seems the command, based on dbatools docs | Restore-DbaDatabase looks at a path and by default doesn’t ignore diff backups, so I’d think it would work without the -WithReplace? That’s a guess, based on the fact that one of the parameters is IgnoreDiffBackup which is clealy designed to ignore and only restore the latest full backup. Again, you should be able to test against a test database, and run it without it, to see if the diffs get added into the existing DB.