HOWTO: Backing up vCenter host issues

PowerShell script exchange

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby ThomasMc » Thu Apr 12, 2012 4:28 pm

Ian Cook wrote:Hi Thomas, really sorry for the slow responses, been busy on another project.

Yes

Windows Server 2008 R2 SP1
Veeam V6 HF3
SQL Express 2008 Local DB

Thanks

Ian


Hi Ian, I too are sorry for the slow response, I'll setup a small lab and see if I can reproduce the error and get back to you :)
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby ThomasMc » Fri Apr 13, 2012 6:55 pm

Tested it on 2005 and 2008(OS Win2008) both working as expected Ian

2005
Code: Select all
StatisticsEnabled                : False
ConnectionString                 : Server=COOR01\VEEAM;Database=VeeamBackup;Integrated Security=SSPI;
ConnectionTimeout                : 15
Database                         : VeeamBackup
DataSource                       : COOR01\VEEAM
PacketSize                       : 8000
ServerVersion                    : 09.00.5000
WorkstationId                    : COOR01
FireInfoMessageEventOnUserErrors : False
State                            : Open
Site                             :
Container                        :


2008
Code: Select all
StatisticsEnabled                : False
ConnectionString                 : Server=COOR01\SQLExpress;Database=VeeamBackup;Integrated Security=SSPI;
ConnectionTimeout                : 15
Database                         : VeeamBackup
DataSource                       : COOR01\SQLExpress
PacketSize                       : 8000
ServerVersion                    : 10.00.1600
WorkstationId                    : COOR01
FireInfoMessageEventOnUserErrors : False
State                            : Open
Site                             :
Container                        :
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby tc.gan » Tue Apr 24, 2012 7:55 am

Ian Cook wrote:Hi Thomas, sorry for the slow reply, been a bit busy this week.

Ran the updated script, and this is the output
Code: Select all
"Error: Exception calling "Open" with "0" argument(s): "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)

I have already been through the settings to allow remote connections, as its SQL Express 2008

Thankis again for the assistance

Ian


i having the same error msg . my Veeam B & R is win2k8 R2 SP1 with latest patches, SQL2005 Express Bundle with Veeam( Default setting) , Enabled TCP/IP & Names Pipes Protocol At SQL Server configuration Manger. My custom scripts as below , even i change server name to ip address also same result. Please help. TQVM

asnp "VeeamPSSnapIn" -ErrorAction SilentlyContinue

$VCVMName = "vcenter"
$serverName = "$env:VMSVEEAM10\VEEAM"
$databaseName = "VeeamBackup"

$vc = Find-VBRViEntity -Name $VCVMName | ?{$_.Reference -notlike "vm-*"}

$conn = New-Object System.Data.SQLClient.SQLConnection
$conn.ConnectionString = "Server=$serverName;Database=$databaseName;Integrated Security=SSPI;"

$cmd = New-Object System.Data.SQLClient.SQLCommand
$cmd.Connection = $conn
$cmd.CommandText = "UPDATE [BObjects] set host_id = '$($vc.ConnHost.Id)',
object_id = '$($vc.Reference)',
path = '$($vc.Path)' WHERE object_name = '$VCVMName' AND object_id NOT LIKE 'vm%'"

try
{
$conn.Open()
}
catch
{
"Error: $_"
break
}

try
{
$cmd.ExecuteNonQuery() | Out-Null
}
catch
{
Write-Warning "Update failed"
}
finally
{
$conn.Close()
}
tc.gan
Influencer
 
Posts: 10
Liked: never
Joined: Fri Nov 04, 2011 11:05 am
Full Name: Gan Tien Chor

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby ThomasMc » Tue Apr 24, 2012 9:48 am 1 person likes this post

I have updated the comments on my site, the issues is with the server name part

Code: Select all
$serverName = "$env:VMSVEEAM10\VEEAM"


$env:COMPUTERNAME is a environment variable in PS that will get the local computer name and normally you wouldn't have to change it.


Code: Select all
#acceptable values
$serverName = "$env:COMPUTERNAME\VEEAM"
#or
$serverName = "VMSVEEAM10\VEEAM"
#but not
$serverName = "$env:VMSVEEAM10\VEEAM"
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby tc.gan » Mon Apr 30, 2012 2:19 am

Hi Thomas ,

i did change the server name to VMSVEEAM10\VEEAM , but now the error message is "Warning : Updated failed" , anything that i did wrong? . Thank you very much for your assistant.
tc.gan
Influencer
 
Posts: 10
Liked: never
Joined: Fri Nov 04, 2011 11:05 am
Full Name: Gan Tien Chor

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby ThomasMc » Mon Apr 30, 2012 10:18 am

It will probably be a duplicate entry that's causing your issue now, to confirm this can your change

Code: Select all
try
{
$cmd.ExecuteNonQuery() | Out-Null
}
catch
{
Write-Warning "Update failed"
}
finally
{
$conn.Close()
}


to

Code: Select all
try
{
$cmd.ExecuteNonQuery() | Out-Null
}
catch
{
"Error: $_"
}
finally
{
$conn.Close()
}
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby tc.gan » Fri May 04, 2012 4:06 am

Hi Thomas,

Thanks for fast reply, but i was busy past few days. i'd just tested the modified script at My lab & it is working fine now. i'll try at customer site next week. Tqvm for your help.By the way, what's your meaning of duplicate entry that's causing my issue? i'm so sorry, i m not good of Powershell command...

Regards,
Gan
tc.gan
Influencer
 
Posts: 10
Liked: never
Joined: Fri Nov 04, 2011 11:05 am
Full Name: Gan Tien Chor

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby ThomasMc » Fri May 04, 2012 12:00 pm

The duplicate entry is created if you've every used the manual way of updating the vCenter job after vMotion

1) vMotion vCenter VM
2) Edit job to remove old VC object and add in the new one via the GUI

Veeam will treat this as a new VM being added to the job and add another entry to its BObjects table, so you will have something like below

Code: Select all
2d800d24-aee1-4f08-9027-56fac01cff4f   1253   vCenter01.vPowerCLI.Local
3f620ec5-1f4b-440a-aa36-fc16601053e2   1234   vCenter01.vPowerCLI.Local


When you run the script it will attempt to update BOTH records with the same data and break the rules so the update will through an exception.
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby tc.gan » Wed May 09, 2012 1:52 am

Hi Thomas,


i tried on customer site. but failed with below message

Error: Exception calling "ExecuteNonQuery" with "0" argument(s): "Cannot insert duplicate key row in object 'dbo.BObjects' with unique index 'IX_BObjects'.
The statement has been terminated."

I tried delete vcenter backup job & delete from disk , then recreate & perform vCenter backup job . But problem still persist with same error message.

The only different between Lab & customer site are:
1)vcenter's VM name , Veeam's Server name
2)Lab using local disk , customer using SAN storage.

Thank you very much with your assistant.
tc.gan
Influencer
 
Posts: 10
Liked: never
Joined: Fri Nov 04, 2011 11:05 am
Full Name: Gan Tien Chor

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby tc.gan » Wed May 09, 2012 1:58 am

Sorry 2 more different are
1)Lab using vSphere 5.0 & vCenter 5 , customer using vSphere 4.1 with vCenter 4.1
tc.gan
Influencer
 
Posts: 10
Liked: never
Joined: Fri Nov 04, 2011 11:05 am
Full Name: Gan Tien Chor

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby ThomasMc » Wed May 09, 2012 9:20 am

Like said, the duplicate entry is in the DB itself and apart from removing it from there you cannot fix it from the GUI
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby tc.gan » Fri May 11, 2012 2:22 am

Dear Thomas,

Is it possible to fix it through SQL 2005 express Management Studio? or must use powershell to fix it? May i know how to do that (procedure)? tqvm.

Regards
Gan
tc.gan
Influencer
 
Posts: 10
Liked: never
Joined: Fri Nov 04, 2011 11:05 am
Full Name: Gan Tien Chor

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby ThomasMc » Fri May 11, 2012 4:18 pm

Yes and Both but is unsupported by Veeam, I'm not going to detail what you should do but have made a short video of how you could do it :D

BACKUP DB
BACKUP DB

Remove duplicate VC Object via SQL Management Express

If the video isn't enough or you don't understand it then please don't attempt it.
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby Ian Cook » Wed May 23, 2012 11:07 am

Thanks for the time and effort you have put in Thomas, again im sorry for the slow repsonses.

I will test this change and get back to you :)

Thanks again :)
Ian Cook
Influencer
 
Posts: 10
Liked: never
Joined: Thu Oct 06, 2011 8:03 am
Full Name: Ian Cook

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby Ian Cook » Wed May 23, 2012 11:58 am

Ah the little computername change seems to have resolved my issues, thanks again Thomas :)
Ian Cook
Influencer
 
Posts: 10
Liked: never
Joined: Thu Oct 06, 2011 8:03 am
Full Name: Ian Cook

PreviousNext

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests