PowerShell script exchange
Post Reply
MattFlowers
Novice
Posts: 8
Liked: 2 times
Joined: Feb 26, 2016 4:26 pm
Full Name: Mathew Flowers
Contact:

Help - Restore SQL database with Powershell

Post by MattFlowers »

We make a copy of our main production SQL database and restore it every Sunday. Right now we use SQL agent to automatically run scripts to save the database to local disk and restore it to another server. I want to use Veeam to restore the database to save space but I can not get powershell to work correctly.

Here is my script:

Code: Select all

Add-PSSnapin -Name VeeamPSSnapIn
$restorepoint = Get-VBRApplicationRestorePoint -SQL -Name "ProductionSQL"
$ProductionDatabase = Get-VBRSQLDatabase -ApplicationRestorePoint $restorepoint[-1] -Name "ProductionDatabase"
$guestcreds = Get-VBRCredentials -Name "DOMAIN\VeeamSvc"
$sqlcreds = Get-VBRCredentials -Name "DOMAIN\VeeamSvc"
Start-VBRSQLDatabaseRestore -Database $ProductionDatabase -ServerName TestSQLServer -DatabaseName ProductionDatabaseTest -GuestCredentials $guestcreds -SqlCredentials $sqlcreds -Wait

When I run this script I can see the job start on the Veeam B&R console but it fails with this error:

Code: Select all

"2/26/2016 11:35:32 AM Error    Database restore failed: ExplorerManagementService: Failed to wait for OIB mounted. MountId: [644f5f51-7155-49cd-84eb-b02b572f9a62], Timeout: [00:00:05] (sessionId = 'ee88c510-6f59-43a4-9532-cd90b50fdee9')"
I have no idea what this error means. I tried to contact veeam support about this but they wont provide me any support for powershell and said I would need post in the forums.

One thing I can think that might be causing this issue is lack file path in the script. When you restore something in Veeam, it will ask you the file path and file name (restoring to a different location) but with the powershell commands, I didn't see that option. Also, when you create a SQL script to restore a database to another location, you need to specify the database location/name in the script. The server that I am restoring to, doesn't have the same drive letters and file paths as the original server.

Thank you for any help!!!
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Help - Restore SQL database with Powershell

Post by veremin »

Can you tell whether you get the same issue if execute restore either via VESQL or via Enterprise Manager? Also, would you mind providing me with the support ticket number, so that I can take a look at it? Thanks.
MattFlowers
Novice
Posts: 8
Liked: 2 times
Joined: Feb 26, 2016 4:26 pm
Full Name: Mathew Flowers
Contact:

Re: Help - Restore SQL database with Powershell

Post by MattFlowers »

Here is my ticket number:
Request ID :##33251##]

I just tried to restore the database using VESQL and it failed as well. Here is the Error:

Code: Select all

"Database restore failed: ExplorerManagementService: Failed to wait for OIB mounted. MountId: [644f5f51-7155-49cd-84eb-b02b572f9a62], Timeout: [00:00:05] (sessionId = 'ee88c510-6f59-43a4-9532-cd90b50fdee9') iSCSI target was not found.  --tr:Failed to call DoRpc.  [CmdName MSiSCSIMountTargetDisks].  iSCSI target was not found."
This sounds like Veeam is trying to mount the iSCSI disk to do the restore. I thought that Veeam used network transport mode to backup and restore SQL? I checked Transport mode on the VMware Proxy and 'Automatic selection' and 'Failover to network mode if primary mode fails, or is unavailable' is checked.

Thank you for the help!!
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Help - Restore SQL database with Powershell

Post by veremin »

Request ID :##33251##
Unfortunately, that doesn't look like a valid support ticket ID.
This sounds like Veeam is trying to mount the iSCSI disk to do the restore.
While performing SQL db restore, VB&R creates an additional mount point on the original VM, using ISCSI initiator.
Database restore failed: ExplorerManagementService: Failed to wait for OIB mounted.
Aren't you using Windows 2003 (that doesn't ISCSI initiator installed) as a staging server by any chance?

Thanks.
MattFlowers
Novice
Posts: 8
Liked: 2 times
Joined: Feb 26, 2016 4:26 pm
Full Name: Mathew Flowers
Contact:

Re: Help - Restore SQL database with Powershell

Post by MattFlowers »

Sorry about that, I gave you the wrong case number (I have a case open with our offsite storage provider).

case 01707432

I am using server 2012 R2 as the Veeam server and proxy and ISCSI initiator is setup and installed. The server it is backing up from is server 2012R2 and the server it is restoring to is server 2012R2. I'm pretty sure the iSCSI is working fine, as I see "2/28/2016 10:03:18 PM :: Using backup proxy VMware Backup Proxy for disk Hard disk 5 [san]" on all the servers that are getting backed up.
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Help - Restore SQL database with Powershell

Post by veremin »

I'd recommend re-opening a case, if the case has been closed already, and notifying support engineer about the issue not being PowerShell-specific one.

The fact that the problem can be reproduced without PowerShell suggests that the root cause lies outside of snap-in.

Thanks.
Dave338
Enthusiast
Posts: 40
Liked: 5 times
Joined: Jan 27, 2015 12:21 pm
Full Name: David
Contact:

Re: Help - Restore SQL database with Powershell

Post by Dave338 »

Exactly same case here restoring a SQL backup over another server (that I have restored other times without problems past month)

I'm trying to restart servers, if not I will open a case.

Regards.
Dave338
Enthusiast
Posts: 40
Liked: 5 times
Joined: Jan 27, 2015 12:21 pm
Full Name: David
Contact:

Re: Help - Restore SQL database with Powershell

Post by Dave338 » 1 person likes this post

Hello again.

Restarting the destination server solved the problem for me. Now is restoring like always :)

Regards.
jcapone
Influencer
Posts: 15
Liked: 1 time
Joined: Mar 01, 2016 9:28 pm
Full Name: John Capone
Contact:

Re: Help - Restore SQL database with Powershell

Post by jcapone »

Were you able to get this issue resolved? We are doing the same thing (restore of production database onto a test database), but through Veeam SQL Explorer, and are getting the exact same error message. I have opened a ticket with Veeam Support, waiting to hear back.
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Help - Restore SQL database with Powershell

Post by veremin »

Based on the case, installing Update 1 has solved the problem for the OP. Can you confirm that you're on the latest product version?

Also, can you post your ticket number for the convenience of future readers?

Thanks.
jcapone
Influencer
Posts: 15
Liked: 1 time
Joined: Mar 01, 2016 9:28 pm
Full Name: John Capone
Contact:

Re: Help - Restore SQL database with Powershell

Post by jcapone » 1 person likes this post

Certainly, the case number is 01841116. We are on 9.0.0.1491 (Update 1).
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Help - Restore SQL database with Powershell

Post by veremin »

Appreciated. If you have a time, kindly, update the topic with the found resolution. Though, it seems that simple server reboot helps in overwhelming majority of cases. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests