PowerShell script exchange
Post Reply
datadrop
Novice
Posts: 7
Liked: 1 time
Joined: May 13, 2014 10:43 am
Full Name: Ulrich Pense
Contact:

PowerShell - Check state of SQL Database Restore

Post by datadrop »

Hi,

currently I'm working on a PowerShell script for restoring SQL databases using the Explorer for MS SQL cmdlets. So far the script is working and the databases get restored. The problem is when to stop the VESQLRestoreSession. For that I need to know when the database restore has completed successfully.

Which object method/property, Veeam PowerShell query or cmdlet would give me that information? In the GUI it's easy to see - as soon as the backup gets unmounted, you're done with restoring. And I don't want to start the script and then check in the GUI, if the restore has been successful.

Does anybody have an idea where to look? Thanks in advance for your input.
tdewin
Veeam Software
Posts: 1818
Liked: 655 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: PowerShell - Check state of SQL Database Restore

Post by tdewin »

Not sure but is it popping up with get-vbrrestoresession?
https://helpcenter.veeam.com/docs/backu ... ml?ver=100
datadrop
Novice
Posts: 7
Liked: 1 time
Joined: May 13, 2014 10:43 am
Full Name: Ulrich Pense
Contact:

Re: PowerShell - Check state of SQL Database Restore

Post by datadrop »

In my case I'm working with a VESQLRestoreSession, since I'm using the Veeam Explorer for SQL. I'll have to check if a VESQLRestoreSession also opens a vbrrestoresession, which hopefully will give me different or more information. I'll give it a try.
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: PowerShell - Check state of SQL Database Restore

Post by jhoughes »

You should be getting a progress bar if you are running the restore session interactively. If not, whatever script you are running will not run the next line of code while the 'Restore-VESQLDatabase' cmdlet is running.

So your script would essentially be paused until the individual DB restore was complete, whether that is a success or error.

You only need to wait to run Stop-VESQLRestoreSession until after you have completed all of the DB restores that you need, or until you completed other testing against the SQL environment to determine your own success criteria for the restore actions of that session.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
datadrop
Novice
Posts: 7
Liked: 1 time
Joined: May 13, 2014 10:43 am
Full Name: Ulrich Pense
Contact:

Re: PowerShell - Check state of SQL Database Restore

Post by datadrop »

You're right, I've just made a test. It works as you've said. The difference is, that the backup server yesterday was upgraded to version 10. When I made my first tests under version 9.5 U4a the restore session was stopped, before the restore had completed. I could reproduce that and thus I was looking for the solution, I mentioned above. Must have been a bug, which seems to be solved with version 10. Thanks for your input.
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests