HOWTO: Backing up vCenter host issues

PowerShell script exchange

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby fcastro » Wed Jul 18, 2012 5:33 pm

i have 2: one for vcenter and another for host
they differ on Path, Id, VmFolderName and Reference (host doesn't start by vm, it is only a number)
if this is the issue i believe you already addressed this earlier. if so can you please provide script or steps on management studio for sqlexpress2008 r2 to have the fix.

thanks
fcastro
Novice
 
Posts: 8
Liked: never
Joined: Thu Apr 05, 2012 10:52 am
Full Name: Fausto Castro

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby fcastro » Thu Jul 19, 2012 10:29 am

removed through sql the esxi hosts and with only the vcenter in the dbo.BObjects it gives the same error:

GUID:

Lines Words Characters Property
----- ----- ---------- --------
0
Error: Exception calling "ExecuteNonQuery" with "0" argument(s): "Conversion fa
iled when converting from a character string to uniqueidentifier."

regards
fcastro
Novice
 
Posts: 8
Liked: never
Joined: Thu Apr 05, 2012 10:52 am
Full Name: Fausto Castro

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby murda » Thu Jul 19, 2012 2:45 pm

This is my code and when I launch this from the Veeam Powershell I get the following reply.

Code: Select all
asnp "VeeamPSSnapIn" -ErrorAction SilentlyContinue

$VCVMName = "TLOVC01.pce.local"
$serverName = "TLOSQL2\Veeam"           
$databaseName = "Veeam"

$vc = Find-VBRViEntity -Name $VCVMName | ?{($_.Reference -notlike "vm-*") -AND ($null -ne $_.Reference)}
     
$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
{
$cmd.ExecuteNonQuery() | Out-Null
}
catch
{
   "GUID: $($vc.Reference)"
   $vc.Reference | Measure-Object -Character
   "Error: $_"
   break
}
finally
{
$conn.Close()
}



GUID:

Lines Words Characters Property
----- ----- ---------- --------
0
Error: Exception calling "ExecuteNonQuery" with "0" argument(s): "ExecuteNonQue
ry requires an open and available Connection. The connection's current state is
closed."
murda
Enthusiast
 
Posts: 38
Liked: never
Joined: Fri Dec 18, 2009 10:05 am
Full Name: murda

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby ThomasMc » Thu Jul 19, 2012 6:51 pm

The above code won't work because you never opened the connection to the SQL server, use the original code and make the small edit I mentioned above and report back: http://forums.veeam.com/viewtopic.php?f=26&t=9301&start=15#p41616
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 fcastro » Fri Jul 20, 2012 8:04 am

(info)
Thomas, sent private message of solicited info.
fcastro
Novice
 
Posts: 8
Liked: never
Joined: Thu Apr 05, 2012 10:52 am
Full Name: Fausto Castro

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby ThomasMc » Fri Jul 20, 2012 4:07 pm

I've been playing around with the script all day and think I know what the problem is, if you could run this one for me and report the error in full

Code: Select all

Add-PSSnapin -Name "VeeamPSSnapIn" -ErrorAction SilentlyContinue

$VCVMName = "vc01.vpowercli.local"
#$VCJobName = "VC Backup"
$serverName = "$env:computername\VEEAM"           
$databaseName = "VeeamBackup01"

#$cvc = Get-VBRJob -Name $VCJobName | Get-VBRJobObject -Name $VCVMName
$vc = Find-VBRViEntity -Name $VCVMName | ?{($_.Reference -notlike "vm-*") -AND ($null -ne $_.Reference)}
     
$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%'"

#if ($cvc.Location -eq $vc.Path) {
#   "The VM hasn't moved" | Out-Default
#   Sleep 15
#   Exit
#}

try
{
   $conn.Open()
}
catch
{
   Write-Warning "ERROR: $_"
}

if ($conn.State -eq "Open") {
   try
   {
      $cmd.ExecuteNonQuery() | Out-Null
   }
   catch
   {
      Write-Warning "ERROR: $_"
   }
   finally
   {
      $conn.Close()
   }
} else {
   "The connection is closed" | Out-Default
}
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 fcastro » Mon Jul 23, 2012 10:49 am

results sent
fcastro
Novice
 
Posts: 8
Liked: never
Joined: Thu Apr 05, 2012 10:52 am
Full Name: Fausto Castro

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby murda » Mon Jul 23, 2012 2:21 pm

ThomasMc wrote:The above code won't work because you never opened the connection to the SQL server, use the original code and make the small edit I mentioned above and report back: http://forums.veeam.com/viewtopic.php?f=26&t=9301&start=15#p41616


Oké,

I tried this code now:

Code: Select all
asnp "VeeamPSSnapIn" -ErrorAction SilentlyContinue

$VCVMName = "TLOVC01.pce.local"
$serverName = "TLOSQL2\Veeam"           
$databaseName = "Veeam"

$vc = Find-VBRViEntity -Name $VCVMName | ?{($_.Reference -notlike "vm-*") -AND ($null -ne $_.Reference)}
     
$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
{
   Write-Warning "Couldn't open connection"
   break
}

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


Still getting the "couldn't open connection" message :?

TLOSQL2 = WIN2008 R2 + SQL 2008 R2
TLOVC01 = WIN2008 R2

Backup name from Veeam job = Backup TLOSQL2
murda
Enthusiast
 
Posts: 38
Liked: never
Joined: Fri Dec 18, 2009 10:05 am
Full Name: murda

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby fcastro » Mon Jul 23, 2012 2:26 pm

shouldn't be the veeam database name VeeamBackup?
fcastro
Novice
 
Posts: 8
Liked: never
Joined: Thu Apr 05, 2012 10:52 am
Full Name: Fausto Castro

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby murda » Mon Jul 23, 2012 2:35 pm

If I remember correctly I changed the database name when I installed Backup & Replication.
I just checked again on my DB server and there are 3 DB's.

Veeam
VeeamBackupReporting
VeeamOne
murda
Enthusiast
 
Posts: 38
Liked: never
Joined: Fri Dec 18, 2009 10:05 am
Full Name: murda

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby ThomasMc » Mon Jul 23, 2012 5:00 pm

@murda
can you try the updated code that I posted @ viewtopic.php?f=26&t=9301&start=60#p58549

@fcastro I'll get back to you RE: the PM
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 murda » Tue Jul 24, 2012 11:47 am

ThomasMc wrote:@murda
can you try the updated code that I posted @ viewtopic.php?f=26&t=9301&start=60#p58549


Code: Select all
Add-PSSnapin -Name "VeeamPSSnapIn" -ErrorAction SilentlyContinue

$VCVMName = "tlovc01.pce.local"
#$VCJobName = "Backup TLOSQL2"
$serverName = "TLOSQL2\Veeam"           
$databaseName = "Veeam"

#$cvc = Get-VBRJob -Name $VCJobName | Get-VBRJobObject -Name $VCVMName
$vc = Find-VBRViEntity -Name $VCVMName | ?{($_.Reference -notlike "vm-*") -AND ($null -ne $_.Reference)}
     
$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%'"

#if ($cvc.Location -eq $vc.Path) {
#   "The VM hasn't moved" | Out-Default
#   Sleep 15
#   Exit
#}

try
{
   $conn.Open()
}
catch
{
   Write-Warning "ERROR: $_"
}

if ($conn.State -eq "Open") {
   try
   {
      $cmd.ExecuteNonQuery() | Out-Null
   }
   catch
   {
      Write-Warning "ERROR: $_"
   }
   finally
   {
      $conn.Close()
   }
} else {
   "The connection is closed" | Out-Default
}


gives me the following:

WARNING: 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: 26 - Error
Locating Server/Instance Specified)"
murda
Enthusiast
 
Posts: 38
Liked: never
Joined: Fri Dec 18, 2009 10:05 am
Full Name: murda

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby murda » Wed Jul 25, 2012 6:59 am

Code: Select all
$serverName = "TLOSQL2\Veeam" 


TLOSQL2 = server hosting Veeam & vCenter DB.
Veeam = Database on TLOSQL2

Is this correct?
murda
Enthusiast
 
Posts: 38
Liked: never
Joined: Fri Dec 18, 2009 10:05 am
Full Name: murda

Re: HOWTO: Backing up vCenter host issues

Veeam Logoby ThomasMc » Thu Jul 26, 2012 12:34 am

No it's the server name/ip and instance name
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Failed to freeze guest warning, how to resolve with DRS?

Veeam Logoby electricd7 » Mon Aug 13, 2012 1:45 pm

[merged]

Hello,

I have a job which runs nightly which includes our virtualcenter server. This job has a warning nightly stating " 8/12/2012 10:03:08 PM :: Unable to release guest. Details: VSSControl: Failed to freeze guest, wait timeout". Now I was able to find a knowledge base article KB1051 (http://www.veeam.com/KB1051) describing this problem exactly. The resolution, however, leaves a lot to be desired unless I am missing something. It says we should add the host which manages vCenter manually and run the backup from that host instead of using vCenter for this job. That is all fine and good until you factor in DRS and the fact that you really have no idea which host vCenter is running on from day-to-day. How do I solve this problem in an enterprise running DRS with 14 hosts? Surely there is another way to resolve this?

ED7
electricd7
Expert
 
Posts: 103
Liked: 5 times
Joined: Tue Mar 27, 2012 10:13 pm
Full Name: Chad Killion

PreviousNext

Return to PowerShell



Who is online

Users browsing this forum: capedFef and 11 guests