Automation

 View Only
  • 1.  Snapshot files left behind but not picked up causing a nightmare

    Posted Mar 26, 2009 02:11 PM

    Hello all, I am after a bit of advice from someone.

    I had the proverbial nightmare situation yesterday where one of my customers lost a number of critical servers due to LUN's filling up. The fault in essence was due to an unnamed 3rd party backup software leaving snapshots behind when they should have been committed. Unnamed due to chats with Vmware whilst fixing the issue showed that it happens to a number of the 3rd party backup apps. To compound my issue the Virtual Centre was displaying incorrect space availability for the Datastores. Snapshot Manager and PowerGUI didn't show any sign of snapshots being left. Happy days, so after a very long day and night cold cloning disks to recover the servers I need to come up with a better way to monitor the bleedin LUN's LOL.

    Has anyone got advice or know of any scripts where I can automate space checking left on the LUN's I think I may have one that I can change to do what I need but if someone has a tried and tested one I would much appreciate it. To a degree, more importantly is there a script or is there an app or plugin where I can automate checking for snapshots that the standard snapshot manager in VC and powerscripts don't pick up. I need to be able to automate it as I don't have the ability to check this customer daily and need to be able to cover it for some colleagues.

    All help appreciated and feel free to have a laugh as I am now at my expense especially if you can point me to a way of doing it.

    Cheers

    H



  • 2.  RE: Snapshot files left behind but not picked up causing a nightmare

    Posted Mar 26, 2009 02:19 PM

    here is one to find orphaned vmdks:

    $arrayVC = "virtualcenter-server-name"
    
    Foreach ($strVC in $arrayVC)
    {
    	Connect-VIServer $strVC 
    	$arrUsedDisks = Get-VM | Get-HardDisk | %{$_.filename}
    	$arrUsedDisks += get-template | Get-HardDisk | %{$_.filename}
    	$arrDS = Get-Datastore
    	Foreach ($strDatastore in $arrDS)
    	{
    	   $strDatastoreName = $strDatastore.name
    	   $ds = Get-Datastore -Name $strDatastoreName | %{Get-View $_.Id}
    	   $fileQueryFlags = New-Object VMware.Vim.FileQueryFlags
    	   $fileQueryFlags.FileSize = $true
    	   $fileQueryFlags.FileType = $true
    	   $fileQueryFlags.Modification = $true
    	   $searchSpec = New-Object VMware.Vim.HostDatastoreBrowserSearchSpec
    	   $searchSpec.details = $fileQueryFlags
    	   $searchSpec.sortFoldersFirst = $true
    	   $dsBrowser = Get-View $ds.browser
    	   $rootPath = ""
    	   $searchResult = $dsBrowser.SearchDatastoreSubFolders($rootPath, $searchSpec)
    	   $myCol = @()
    	   foreach ($folder in $searchResult)
    	   {
    	      foreach ($fileResult in $folder.File)
    	      {
                 $file = "" | select Name, FullPath			
    		     $file.Name = $fileResult.Path
    		     $strFilename = $file.Name
    		     IF ($strFilename)
    		     {
    		     IF ($strFilename.Contains(".vmdk")) 
    		     {
    		     IF (!$strFilename.Contains("-flat.vmdk"))
    		     {
    		     IF (!$strFilename.Contains("delta.vmdk"))		  
    		     {
    		        $strCheckfile = "*"+$file.Name+"*"
    			 IF ($arrUsedDisks -Like $strCheckfile){}
    	         ELSE 
    			 {			 
    			 $strOutput = $strDatastoreName + " Orphaned VMDK Found: " + $strFilename
    			 $strOutput
    			 }	         
    		     }
    		     }		  
    		     }
    		     }
    	      }
    	   }       
       }	
    }
    

    and here is one to find all the snapshots out there:

    Get-VM | Get-Snapshot | `
    	Select Name, @{Name="VM Name" ; `
    	Expression={$_.VM.Name}}
    

    http://www.vmwarescripting.com



  • 3.  RE: Snapshot files left behind but not picked up causing a nightmare

    Posted Mar 26, 2009 03:40 PM

    Cheers for the scripts, prob I have with the find all snapshots is the same as other scripts I have and use.

    I have a VM in my farm right now that has delta files there and I need to cold clone them to commit them, prob is using your script, my scripts, Snapshot Manager or PowerGUI scripts, it does not show that these files are there and need to be committed. I appreciate the response though thanx.

    H



  • 4.  RE: Snapshot files left behind but not picked up causing a nightmare

    Posted Mar 26, 2009 04:43 PM

    did you look at the orphaned vmdk script? its probably what your looking for

    http://www.vmwarescripting.com



  • 5.  RE: Snapshot files left behind but not picked up causing a nightmare

    Posted Mar 26, 2009 04:19 PM

    Hi,

    I am actually facing a very similar issue (without disaster as I've detected it before ...) with hot-cloning VMs script in a DRP objective. The resulting VM, when replaced by a new version leaves it's .VMSS file orphan.

    I actually am working on a cleanup solution ...

    Regards - Hervé



  • 6.  RE: Snapshot files left behind but not picked up causing a nightmare

    Posted Mar 26, 2009 04:52 PM

    Hi Kevin,

    This can email you based on a free space threshold on your datastores

    http://communities.vmware.com/docs/DOC-9663

    Joe

    Remember to back EVERYTHING up before you change ANYTHING