Restore DbaDatabase

Stuart Moore edited this page Apr 27, 2017 · 3 revisions

Restore-DbaDatabase is the main entry point to the restore functions.

The function itself doesn't do much apart from check paramters, pass file inputs to the correct parsing function and marshall the internal functions in order

BEGIN

The BEGIN section is purely concerned with checking parameters are correct.

In here we also check whether we're working locally to the target SQL Server instance or not. If we are local then all forms of file input are available. If non local then only UNC paths or local paths via Get-XpDirTreeRestoreFile

PROCESS

The PROCESS section is predomniantly dealing with the passed in files and paths. We can't progress until we have all the files passed in (Sod's Law states that the last file we get will be the first one we need).

END

The END section does the actual restore work

If not running locally use Test-SqlPath to check that the target instance can see the requested restore paths

At this point $BackupFiles contains all files that passed the basic filtering in the BEGIN section. For debugging, if you can uncomment the return to have the function stop here so you can see what files have been collected.

These are all passed to Get-FilteredRestoreFile, which will check they are SQL Server backup files and return them filtered down as required by parameters, grouped by database into $AllFilteredFiles

At this point $AllFilteredFiles can be returned so you could peak at the raw filtered backup files.

The backup file details are group together in $AllFilteredFiles, so we can ForEach through the array to restore each database.

If the set of backup files pass the Test-DbaLsnChain and Test-DbaRestoreVersion tests then the files are passed off to Restore-DbFromFilteredArray to perform the actual restore

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.