PowerShell script exchange
fcastro
Novice
Posts: 8
Liked: never
Joined: Apr 05, 2012 10:52 am
Full Name: Fausto Castro
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by fcastro »

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: Apr 05, 2012 10:52 am
Full Name: Fausto Castro
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by fcastro »

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
murda
Enthusiast
Posts: 38
Liked: never
Joined: Dec 18, 2009 10:05 am
Full Name: murda
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by murda »

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."
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by ThomasMc »

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 ... =15#p41616
fcastro
Novice
Posts: 8
Liked: never
Joined: Apr 05, 2012 10:52 am
Full Name: Fausto Castro
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by fcastro »

(info)
Thomas, sent private message of solicited info.
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by ThomasMc »

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
}
fcastro
Novice
Posts: 8
Liked: never
Joined: Apr 05, 2012 10:52 am
Full Name: Fausto Castro
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by fcastro »

results sent
murda
Enthusiast
Posts: 38
Liked: never
Joined: Dec 18, 2009 10:05 am
Full Name: murda
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by murda »

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 ... =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
fcastro
Novice
Posts: 8
Liked: never
Joined: Apr 05, 2012 10:52 am
Full Name: Fausto Castro
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by fcastro »

shouldn't be the veeam database name VeeamBackup?
murda
Enthusiast
Posts: 38
Liked: never
Joined: Dec 18, 2009 10:05 am
Full Name: murda
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by murda »

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
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by ThomasMc »

@murda
can you try the updated code that I posted @ http://forums.veeam.com/viewtopic.php?f ... =60#p58549

@fcastro I'll get back to you RE: the PM
murda
Enthusiast
Posts: 38
Liked: never
Joined: Dec 18, 2009 10:05 am
Full Name: murda
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by murda »

ThomasMc wrote:@murda
can you try the updated code that I posted @ http://forums.veeam.com/viewtopic.php?f ... =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: Dec 18, 2009 10:05 am
Full Name: murda
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by murda »

Code: Select all

$serverName = "TLOSQL2\Veeam"  
TLOSQL2 = server hosting Veeam & vCenter DB.
Veeam = Database on TLOSQL2

Is this correct?
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by ThomasMc »

No it's the server name/ip and instance name
electricd7
Expert
Posts: 122
Liked: 7 times
Joined: Mar 27, 2012 10:13 pm
Full Name: Chad Killion
Contact:

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

Post by electricd7 »

[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
Gostev
Chief Product Officer
Posts: 31804
Liked: 7298 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by Gostev »

Folks, we are looking at handling vCenter VM backup on the product level in the next major release, so that you don't have to jump through the hoops to achieve this. Appeared to be quite a task to implement this in a reliable manner, but I think devs nailed it.
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by ThomasMc »

That's awesome news :)
dellock6
VeeaMVP
Posts: 6166
Liked: 1971 times
Joined: Jul 26, 2009 3:39 pm
Full Name: Luca Dell'Oca
Location: Varese, Italy
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by dellock6 »

Great news Anton, waiting for it then :)

Luca.
Luca Dell'Oca
Principal EMEA Cloud Architect @ Veeam Software

@dellock6
https://www.virtualtothecore.com/
vExpert 2011 -> 2022
Veeam VMCE #1
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by ThomasMc »

Gostev wrote:Folks, we are looking at handling vCenter VM backup on the product level in the next major release, so that you don't have to jump through the hoops to achieve this. Appeared to be quite a task to implement this in a reliable manner, but I think devs nailed it.
Did this make it into 6.5?
Vitaliy S.
VP, Product Management
Posts: 27371
Liked: 2799 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by Vitaliy S. »

Since 6.5 is not a major release, then the answer is no ;)
pjbryant
Novice
Posts: 9
Liked: never
Joined: Nov 05, 2012 10:58 am
Full Name: P J Bryant
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by pjbryant »

hello all, I'm looking into this one as well, but I am using a different "find the host the VC is on" method. that is only a few short lines. In addition I also temporarily disable DRS from moving the VC to a different host so that the job does not subsequently fail (it happened to me once quite early on in testing!)

Code: Select all

#declare the VC name (as appearing in vCentre display, not the NetBIOS name)
$VCVMName = "vCenter"

#connect to the cluster (sort your credentials how you like...)
$VC = Connect-VIServer $VCVMName -User <Username> -Password <Password>
#disable DRS moving of the VC so we connect correctly (this prevents DRS moving the VC guest to another host before the job runs
get-cluster | Set-Cluster -DrsAutomationLevel PartiallyAutomated -confirm:$false

#Find out on which host vCentre 4.1 is running
$VCGuest=get-vm $VCVMName
$ESXiHost = $VCGuest.vmhost.name
$ESXiHost now is the ESX host *currently* running your VC

to enable the DRS automation once the job has been started (and i recommend waiting a few minutes after the job is started)

Code: Select all

#wait 5 minutes for the Job to get going
Start-Sleep -s 300
#set drs automation back to full automated
get-cluster | Set-Cluster -drsautomationlevel FullyAutomated -confirm:$false 
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by ThomasMc »

I never seen any point in using PowerCLI as the VeeamShell can get what we needed, also why not use the VMotion event to trigger an alarm and run your script? we spoke about that away at the start of this thread :wink:
pbohlken
Novice
Posts: 8
Liked: never
Joined: Jan 09, 2013 3:35 pm
Full Name: Peter Bohlken
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by pbohlken »

When is an update expected?

I also have the same issues with not able to backup vCenter (quiesce). I already installed the latest patch a few days ago that solves problems with snapshots not being removed.
For use is a solution with a script not a real solution.

Thanks!
Vitaliy S.
VP, Product Management
Posts: 27371
Liked: 2799 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by Vitaliy S. »

Gostev wrote:Folks, we are looking at handling vCenter VM backup on the product level in the next major release, so that you don't have to jump through the hoops to achieve this. Appeared to be quite a task to implement this in a reliable manner, but I think devs nailed it.
The next major update that should address this behavior is scheduled for this year.
Unison
Enthusiast
Posts: 96
Liked: 16 times
Joined: Feb 17, 2012 6:02 am
Full Name: Gav
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by Unison »

Cant wait for the next major release :) Hopefully this will be addressed. I imagine everyone with a VC on multiple hosts is suffering this problem - its especially painful for us running replication jobs over the WAN - every time your VC is vmotioned......we have to re transport the base image :( - unless we undertake this unsupported hacking of the database.

Its been an identified issue for years now - hopefully the time is right for a permanent solution to this from veeam. Veeam does do some very impressive and tricky things as you all know - so building a little bit of intelligence in that detects the change of a RefID due to a vMotion will be well within the capabilities of the Veeam Dev team :).

Fingers crossed
ogodt
Novice
Posts: 7
Liked: never
Joined: Mar 11, 2013 12:21 pm
Contact:

[MERGED] VSSControl: Failed to freeze guest, wait timeout

Post by ogodt »

Hi all,

i have a backup job that backs up all my vms ( 11 ) but i get the VSSControl error on my Vcenter i have read http://www.veeam.com/KB1051 but i really cant figure out what to do,
i would like to keep my backup job, because it backs up my entire cluster.

We use Veeam BR 6.5

\Ole
ntrevett
Lurker
Posts: 1
Liked: never
Joined: Aug 09, 2013 8:25 am
Full Name: Nigel Trevett
Contact:

[MERGED] : Backing up vCenter Database Server Best Practice

Post by ntrevett »

Hi,
What is considered the "Best Practice" deployment of a virtual SQL server for a virtual vCenter server so to be able to back it up with Veeam's B&R?
Is it supported by Veeam and Microsoft if you backup a Mirror Target (SQL 2008) or an Always-on replica (SQL 2012)?
I've seen the KB recommending a backup via the host - surely this is more of a work-around!

Thanks in advance for your help
Nigel
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by veremin »

Hi, Nigel.

You have been merged to the existing discussion regarding vCenter VM backup, so, kindly take a look at the answers provided above.

For now one option to go is, indeed, to add a vCenter VM to backup/replication job through a standalone server. However, please be aware that the upcoming version of Veeam Backup and Replication will handle the process of vCenter VM backup more effectively.

Thanks.
Tim783
Influencer
Posts: 15
Liked: never
Joined: Jul 20, 2012 2:05 pm
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by Tim783 »

Gostev wrote:Folks, we are looking at handling vCenter VM backup on the product level in the next major release, so that you don't have to jump through the hoops to achieve this. Appeared to be quite a task to implement this in a reliable manner, but I think devs nailed it.
Hi Gostev,

Did this end up being fixed in v7? I am running v7 and am still unable to backup one of our SQL servers that hosts the vcenter database.

Have to add at the host level to get a successful backup.

Thanks
Vitaliy S.
VP, Product Management
Posts: 27371
Liked: 2799 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: HOWTO: Backing up vCenter host issues

Post by Vitaliy S. »

Yes, this issue has been addressed in v7. If you still experience issues with backing up vCenter Server through the vCenter Server, please contact our technical team for logs review. Thank you!
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests