Help - Restore SQL database with Powershell

PowerShell script exchange

Help - Restore SQL database with Powershell

Veeam Logoby MattFlowers » Fri Feb 26, 2016 4:42 pm

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!!!
MattFlowers
Novice
 
Posts: 4
Liked: never
Joined: Fri Feb 26, 2016 4:26 pm
Full Name: Mathew Flowers

Re: Help - Restore SQL database with Powershell

Veeam Logoby v.Eremin » Mon Feb 29, 2016 11:08 am

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.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Help - Restore SQL database with Powershell

Veeam Logoby MattFlowers » Mon Feb 29, 2016 4:24 pm

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!!
MattFlowers
Novice
 
Posts: 4
Liked: never
Joined: Fri Feb 26, 2016 4:26 pm
Full Name: Mathew Flowers

Re: Help - Restore SQL database with Powershell

Veeam Logoby v.Eremin » Mon Feb 29, 2016 4:41 pm

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.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Help - Restore SQL database with Powershell

Veeam Logoby MattFlowers » Mon Feb 29, 2016 7:29 pm

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.
MattFlowers
Novice
 
Posts: 4
Liked: never
Joined: Fri Feb 26, 2016 4:26 pm
Full Name: Mathew Flowers

Re: Help - Restore SQL database with Powershell

Veeam Logoby v.Eremin » Tue Mar 01, 2016 12:22 pm

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.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Help - Restore SQL database with Powershell

Veeam Logoby Dave338 » Mon Apr 11, 2016 12:38 pm

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: 35
Liked: 5 times
Joined: Tue Jan 27, 2015 12:21 pm
Full Name: David

Re: Help - Restore SQL database with Powershell

Veeam Logoby Dave338 » Mon Apr 11, 2016 1:16 pm 1 person likes this post

Hello again.

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

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

Re: Help - Restore SQL database with Powershell

Veeam Logoby jcapone » Wed Jun 29, 2016 5:45 pm

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.
jcapone
Lurker
 
Posts: 2
Liked: 1 time
Joined: Tue Mar 01, 2016 9:28 pm
Full Name: John Capone

Re: Help - Restore SQL database with Powershell

Veeam Logoby v.Eremin » Thu Jun 30, 2016 7:17 am

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.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Help - Restore SQL database with Powershell

Veeam Logoby jcapone » Thu Jun 30, 2016 12:33 pm 1 person likes this post

Certainly, the case number is 01841116. We are on 9.0.0.1491 (Update 1).
jcapone
Lurker
 
Posts: 2
Liked: 1 time
Joined: Tue Mar 01, 2016 9:28 pm
Full Name: John Capone

Re: Help - Restore SQL database with Powershell

Veeam Logoby v.Eremin » Fri Jul 01, 2016 8:40 am

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.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests