passi1985
Goto Top

VCB 1.5 Trennung von File-Level und Image-Level

Hallo Zusammen,

ist es möglich mit VCB 1.5 ein getrenntes Backup zu erstellen, d.h. file-level und image-level von einer VM?

Wir wollen somit ermöglichen, dass die System Partition als Full-Image gebackuped wird und die Daten Partition nur als File-Backup läuft, so dass wir von dem Backup der Datenpartition jederzeit die Files einzellnt zurücksichern können und das System nur im Notfall Recovern.

Fallbeispiel:
Ich hab meine VM mit C: und D:. Die D ist independent und wird somit nicht im Snapshot berücksichtigt => Beim Backup mit VCB kann ich via Image-Level ein Backup der ganzen VM (C: ohne D: ) erstellen. Nun möchte ich aber noch ein File-Level Backup von D erstellen über VCB, da ich nit übers LAN sichern will. Da die Platte aber independent ist wird sie nicht erkannt.

Hat jemand eine Idee?

Gruß
Pascal

Content-ID: 101099

Url: https://administrator.de/forum/vcb-1-5-trennung-von-file-level-und-image-level-101099.html

Ausgedruckt am: 27.12.2024 um 18:12 Uhr

Dracul
Dracul 15.04.2009 um 14:41:06 Uhr
Goto Top
Ich mache es auf eine Andere Art und Weise.

die Images sichere ich komprimiert mit einem von mir überarbeiteten VB-Skript direkt vom SAN

die Filesicherung mache ich mit Browse-start / browse-end und kopiere mir die geänderten dateien mit Robocopy in ein Backup-Verzeichnis und von dort auf Band.

Alle Laufwerke (RAW-Devices oder VMDK´s) sind Virtuell und abhängig (die Laufwerke für die Images kann ich angeben und somit werden Riesendateien (z.B. Fileserverdaten) vermieden

 


'// ===========================================================================================  
'//   BackupDisk.vbs  
'//   ------------------------------------------  
'//   Uses VCB command line utils, primarily "vcbExport", to do snapshot and perform a full-image  
'//   backup of an *** individual *** VM disk file.  
'//  
'//   Script is designed to be called as "Pre-scan" or "Pre-backup" script by a CommVault sub-client backup job for the VM that is to be backed up  
'//  
'//   This differs from the default vcbMounter.exe utility which enuerates ALL disks in a VM and does   
'//   not enable granular full-image backup of single disk - although it will skip "independent" disks  
'//  
'//   The problem is that if disks are put into independent mode, vcbMounter will also skip them for   
'//   *** File-level *** backups.  
'//  
'//   The "BackupDisk.vbs" script enables selective full-image backup of a specified disk or disks while maintaining  
'//   the ability to perfrom VCB file-level backups of any/all disks within the VM using default VCB scripts   
'//  
'//   It also provides a workaround for the VCB 1.0.2 / ESX 3.0.1 bug that prevents backups of disks on a given VM succedding where that VM  
'//   has multiple disks attached on different LUNs.  
'//     
'//   The script performs the following steps:  
'//   ------------------------------------------  
'//   =>. Reads the values for the following required command-line parameters:  
'//      * FQDN of target VM where disk to be backed up resides  
'//      * Comma-separated list of the SCSI ID/s of the disk or disks within that VM that should be backed up e.g. "scsi0.0" or "scsi0.0,scsi0.1"  
'//          
'//        IMPORTANT NOTE ON FORMAT OF SCSI ID/s PROVIDED TO COMMAND LINE:  
'//        SCSI IDs should always be provided to the command line in the format "scsi[x].[x]" e.g. "scsi0.0"  
'//        In this instance "scsi0.0" will always be the first disk (System drive for Windows servers), "scsi0.1" will be the second disk etc ...  
'//        The SCSI ID for a disk can be obtained by viewing the properties of the VM in Virtual Center  
'//        However, the display format in Virtual Centre will be as "SCSI ([x].[x])" e.g. "SCSI (0.0)"  
'//        !!!! This format should be changed:  remove all spaces and "(" ")" brackets from the way it is displayed.  
'//        For example, "SCSI (0:0)" should be modified to "scsi0.0"  
'//	  
'//   =>. Gets ID of VM using vcbVmName  
'//   =>. Snapshots the VM using vcbSnapshot  
'//   =>. Runs vcbSnapshot with the "-l" parameter to enumerate the disks within the snapshot  
'//   =>. Checks SCSI ID/s of disk/s passed on command line againsts list of disks within snapshot, and returns path of associated VMDK/s on SAN  
'//   =>. For each disk specified on command line, runs vcbExport to export disk in "compact" and "monolithic" format.   
'//      The export path will be [ROOT_MOUNT_PATH_SPECIFIED_IN_CONFIG.js]\[FQDN_OF_VM]\[ORIGINAL_VMDK_FILE_NAME]  
'//      e.g. D:\MNT\vmtest1.emapdev.net\VMTEST1_1.vmdk  
'//   =>. Runs vcbSnapshot a 3rd time to commit the snapshot (i.e. once vcbExport of all specified disks is complete)  
'//        
'//      POST_EXECUTION ASSUMPTIONS FOR COMMVAULT:  
'//      * It will then be assumed that CommVault will back up the exported disk image from the path specified in step 5 above -   
'//          
'//      * It will also be assumed that CommVault will run a "post-backup" script to DELETE the D:\MNT\[VM Name] directory on the VCB server   
'//        after backup completes  
'//  
'//   Prerequisites:  
'//   ------------------------------------------  
'//   * VMWare Consolidated Backup Framework 1.0.x must be installed on system where script is executed  
'//   * The script MUST be located in the VCB_PROXY_FRAMEWORK_INSTALL_DIR\generic folder - along with the other .wsf, .js and .bat files  
'//     By default this is "C:\Program Files\VMware\VMware Consolidated Backup Framework\generic"  
'//   * The config.js file must be correctly configured as per VMWare / CommVault / Emap requirements  
'//   * The constant "VCB_INSTALL_PATH" within the script below must be modified to reflect the location of the VCB executables (vcbExport, vcbSnapshot, vcbVmName etc)  
'//  
'//   Other notes:  
'//   ------------------------------------------  
'//   As per any VCB-based backup, only one backup of the VM specified should be run at any one time (stands to reason)  
'//     
'//   Usage / Syntax:  
'//   ------------------------------------------  
'//   VMbackup.vbs [FQDN_OF_VM] [COMMA_SEP_LIST_OF_SCSI_IDs_FOR_DISKS_TO_BACKUP]  
'//     
'//   Examples:  
'//   ------------------------------------------  
'//   To backup disk 0 on VM "vcbtest1.emapdev.net":  
'//   BackupDisk.vbs vcbtest1.emapdev.net scsi0.0  
'//  
'//   To backup disks 0 and 1 on VM "server1.emap.net":  
'//   BackupDisk.vbs server1.emap.net scsi0.0,scsi0.1  
'//  
'//   Restoring vcbExport backups made with this script:  
'//   ------------------------------------------  
'//   The compact, monolithic .VMDK files created by this script as individual disk backups can be restored by using "vmkfstools -i" on any ESX service console  
'//   The VMDK backup file should be:  
'//   1. Restored to the VCB server local disk using CommVault  
'//   2. Copied to a temp location on one of the ESX servers in the correct VI cluster  
'//   3. Then imported to the correct folder for the target VM (existing or new) using "vmkfstools -i [RESTORED_DISK_FILE_PATH] [TARGET_DISK_FILE_PATH]  
'//   4. Finally, the imported vmdk file should be re-added to the correct VM using ESX command line or Virtual Infrastructure client  
'//  
'//   AUTHOR: Justin Turver, 09/2007  
'// ===========================================================================================  
'//  
'// Changes HIERL 01/2009  
'//  
'// usage of VM-Ware names  
'//  
'// wegen Zertifikatsproblemen den namen "VMware" umgeleitet auf den VC (Host entry xx.xx.xx.xx VMware) (Funktioniert)  
'// SSL einschalten:  
'// [HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMware Consolidated Backup]  
'// "VerifySSLCertificates"=dword:00000001  
'// SSL ausschalten:  
'// [HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMware Consolidated Backup]  
'// "VerifySSLCertificates"=dword:00000000  
'//   
'// Beispiel:  
'// @ECHO OFF  
'// echo ######## 1/19 Vitrual Center #################################  
'// @echo on  
'// cscript /nologo "d:\vcb\generic\BackupDisk.vbs" "EC084479 VC" "scsi0.0,scsi0.1"  
'// @ECHO OFF  
'// echo --------------------------------------------------------------  
'// echo ######## 2/19 Nagios #########################################  
'// @echo on  
'// cscript /nologo "d:\vcb\generic\BackupDisk.vbs" "Nagios" "scsi0.0"  
'// @echo off  
'//   
Option Explicit

'// -----------------------------------------------------------------------------------  
'//                Constants - change to reflect running environment:  
'// -----------------------------------------------------------------------------------  
Const VCB_INSTALL_PATH = "D:\VCB"  
Const HOST = "VMware"   
Const USERNAME = "Administrator"  
Const PASSWORD = "***********"  
Const BACKUPROOT = "K:\\mnt"  
Const SNAPSHOTNAME = "_VCB-BACKUP_"  
Const CONTINUE_IF_VCB_SNAP_FOUND = True		'// Set to true to proceed with backup/export even if there's an existing snapshot of the VM  
Const CONTINUE_IF_BACKUP_DIR_FOUND = True	'// Set to true to proceed with backup/export even if the local backup target directory already exists  
'// -----------------------------------------------------------------------------------  

Const EVT_SUCCESS = 0
Const EVT_ERROR = 1
Const EVT_WARN = 2
Const EVT_INFO = 4

'// Global Variables  
'// ----------------  
Dim oArgs, oWshShell, oExec, oDict, oDictItem, colKeys, oFSO, oBackupFolder
Dim aDisksToBackUp, aSSIDs
Dim iRetVal, i
Dim sVMFQDN, sOutput, sCommandPath, sVmID, sSSID, sSnapNumber, sSnapDelete, sSnapCreate, sDisk, sDisks, sDiskPath, sDiskFile, sKey, sPercentExportComplete
Dim bDiskCheck
Dim start

'// Create global objects  
'// ---------------------  
Set oWshShell = CreateObject("WScript.Shell")  
Set oDict = CreateObject("Scripting.Dictionary")  
Set oFSO = CreateObject("Scripting.FileSystemObject")  


'// ==============================================  
'//                START MAIN:  
'// ==============================================  
start = Now()
LogInfo( "EMAP vcbEXPORT: Starting backup using " & WScript.ScriptFullName )  


'// ==============================================  
'// 1. Get / check command line params:  
'// ==============================================  
LogInfo( "EMAP vcbEXPORT task 1: Checking command-line params for Emap custom VCB Backup script " & WScript.ScriptFullName )  
Set oArgs = WScript.Arguments
If oArgs.Count = 2 Then
	sVMFQDN = Trim((WScript.Arguments(0)))
   ' //     sVMFQDN = chr(34) & sVMFQDN & chr(34)  
	On Error Resume Next
	
	'// aDisksToBackup enthält alle einträge der zu sichernden Daten [1..x]  
	aDisksToBackUp = Split(LCase(WScript.Arguments(1)),",")  
	If Err Then
		LogError("EMAP vcbEXPORT task 1: ERROR: Invalid command-line argument specified for 'disk/s' paramter. ERROR: " & Err.Number & "-" & Err.Description & ". VM: " & sVMFQDN)  
		LogError("Expected Syntax = [script_name] [fqdn_of_vm_to_backup] [comma-separated_list_of_disk_scsi_IDs] e.g. '" & WScript.ScriptName & " mytestvm.emapdev.net scsi0.0,scsi0.1'. VCB BACKUP FAILED!")  
		WScript.Quit(1)
	End If
	On Error Goto 0
Else
	LogError("EMAP vcbEXPORT task 1: ERROR: Invalid command line arguments specified. Syntax = [script_name] [fqdn_of_vm_to_backup] [comma-separated_list_of_disk_scsi_IDs]. VM: " & sVMFQDN & ". VCB BACKUP FAILED!")  
	WScript.Quit(1)
End If
Set oArgs = Nothing
LogInfo( "EMAP vcbEXPORT task 1: Command line successfully parsed. Will attempt to backup server '" & sVMFQDN & "'. The following disks on this server will be backed up: " & WScript.Arguments(1))  


'// ==============================================  
'// 2. Get ID of VM for use when creating snapshot  
'// ==============================================  
oWshShell.LogEvent EVT_INFO, "EMAP vcbEXPORT task 2: Retrieving VM ID of server '" & sVMFQDN & "' for vcbBackup."  
'// HIE Org mit IPAdresse  
'// sVmID = RunCommand(VCB_INSTALL_PATH & "\vcbVmName.exe -h " & HOST & " -u " & USERNAME & " -p " & PASSWORD & " -s ipaddr:" & sVMFQDN,"moref:",False)  
'//   
sVmID = RunCommand(VCB_INSTALL_PATH & "\vcbVmName.exe -h " & HOST & " -u " & USERNAME & " -p " & PASSWORD & " -s Name:" & chr(34) & sVMFQDN & chr(34)  ,"moref:" ,False)  
If Len(Trim(sVmID)) < 10 Then
	LogError("EMAP vcbEXPORT task 2: UNKNOWN ERROR: vcbVmName could did not return the vm-ID for VM: " & sVMFQDN & ":" & sVmID & ". VCB BACKUP FAILED!" & vbCrLf & vbCrLf & sOutput)  
	WScript.Quit(1)
End If
LogInfo( "EMAP vcbEXPORT task 2: ID of VM '" & sVMFQDN & "' returned successfully: " & sVmID & vbCrLf & vbCrLf & sOutput)  
sOutput = ""  


'// ==========================================================================  
'// 3.Create backup folder for VM at designated local mount point (BACKUPROOT)  
'// ==========================================================================  
'// Check if backup folder on vcb proxy server (subfolder to default mount point) exists:  
LogInfo( "EMAP vcbEXPORT task 3: Creating backup folder for '" & sVMFQDN & "' at root path '" & BACKUPROOT & "'.")  
If oFSO.FolderExists(BACKUPROOT & "\" & sVMFQDN & "-CustomDiskBackup") Then  
	If CONTINUE_IF_BACKUP_DIR_FOUND = True Then '// Proceed with backup anyway - remove existing folder and continue  
		'// Log warning as old backup may not have run post-backup cleaup script (post-backup)  
		LogInfo( "EMAP vcbEXPORT task 3: WARNING: vcb export backup folder already exists for VM '" & sVMFQDN & "' at path: '" & BACKUPROOT & "\" & sVMFQDN & "' and 'CONTINUE_IF_BACKUP_DIR_FOUND = True' - will proceed and remove existing backup directory and current backup will continue. NOTE: This folder should have been removed by post-backup script. Check that the correct post-backup script exists for CommVault backup of this server. The fact that it's still there may also mean that the previous backup of this VM failed, or the post-backup script failed. Please check this out. Script " & WScript.ScriptFullName & " will continue to delete the existing directory and all files within. VCB BACKUP WARNING!")  
		'// Try and remove the existing folder and contents  
		On Error Resume Next
		Set oBackupFolder = oFSO.GetFolder(BACKUPROOT & "\" & sVMFQDN & "-CustomDiskBackup")  
		oBackupFolder.Delete  ', True  
		If Err Then
			LogError("EMAP vcbEXPORT task 3: ERROR: Unable to delete an existing vcb export folder '" & BACKUPROOT & "\" & sVMFQDN & "'.for VM '" & sVMFQDN & "'. Check that another backup is not running, or that the folder or files within are not otherwise locked!!!. Error: " & Err.Number & "--" & Err.Description & ". VCB BACKUP FAILED!")  
			WScript.Quit(1)
		End If
		On Error Goto 0
		Set oBackupFolder = Nothing
		WScript.Sleep 2000
	Else
		'// Cancel backup ...  
		LogError("EMAP vcbEXPORT task 3: ERROR: backup target folder for VM '" & BACKUPROOT & "\" & sVMFQDN & "'already exists, and 'CONTINUE_IF_BACKUP_DIR_FOUND' is set to 'FALSE'. Check that another backup is not running, and that any CommVault backup jobs for this VM have the correct post-backup script assigned so that backup directories or mount points for this VM are removed properly once backup is complete. Backup cannot continue for this VM. VCB BACKUP FAILED!")  
		WScript.Quit(1)
	End If
End If
'// Create backup folder for the VM at the specified mount point root 'BACKUPROOT'  
On Error Resume Next
Set oBackupFolder = oFSO.CreateFolder(BACKUPROOT & "\" & sVMFQDN & "-CustomDiskBackup")  
If Err Then
	LogError("EMAP vcbEXPORT task 3: ERROR: Unable to create local vcb export folder '" & BACKUPROOT & "\" & sVMFQDN & "-CustomDiskBackup" & "'.for VM '" & sVMFQDN & "'. Check that another backup is not running, and that the folder does not already exist in a locked state!!!. Error: " & Err.Number & "--" & Err.Description & ". Backup cannot continue for this disk. VCB BACKUP FAILED!")  
	WScript.Quit(1)
Else
	LogInfo( "EMAP vcbEXPORT task 3: Backup folder for VM '" & sVMFQDN & "' created successfully at '" & BACKUPROOT & "\" & sVMFQDN & "-CustomDiskBackup" & "'.")  
End If
On Error Goto 0
Set oBackupFolder = Nothing


'// ==============================================  
'//      4. Check for existing vcbSnapshots   
'// ==============================================  
LogInfo("EMAP vcbEXPORT task 4: Checking for existing VCB snapshots ('_VCB-BACKUP_') for VM: " & sVMFQDN)  
sSSID = RunCommand(VCB_INSTALL_PATH & "\vcbSnapshot.exe -h " & HOST & " -u " & USERNAME & " -p " &  "*******"  & " -f " & sVmID & " " & SNAPSHOTNAME, "ssid:",False)  
If (InStr(LCase(sOutput),"no backup snapshots found") > 0) Or (InStr(LCase(sSSID),"ssid:snapshot") = 0) Then  
	'// No VCB snapshots found  
	LogInfo( "EMAP vcbEXPORT task 4: No existing VCB Snapshots found for VM: " & sVMFQDN & ". Backup will proceed.")  
Else
	'// Existing VCB snapshots found  
	If CONTINUE_IF_VCB_SNAP_FOUND = True Then
		LogInfo( "EMAP vcbEXPORT task 4: Existing VCB Snapshots found for VM: " & sVMFQDN & ", and 'CONTINUE_IF_VCB_SNAP_FOUND = True' - proceeding to delete existing VCB snapshot ...")  
		'// Delete existing VCB snap/s, and continue backup  
		sSnapDelete = RunCommand(VCB_INSTALL_PATH & "\vcbSnapshot.exe -h " & HOST & " -u " & USERNAME & " -p " & PASSWORD & " -d " & sVmID & " " & sSSID, "error",False)  
		'// ### Error wegen Certifikat HIE  
		If InStr(LCase(sSnapDelete), "error") Then   
			LogError("EMAP vcbEXPORT task 4: ERROR: Cannot delete existing snapshot: " & sVMFQDN & ": " & sSSID & ". VCB BACKUP FAILED!" & vbCrLf & vbCrLf & sOutput)  
			WScript.Quit(1)
		Else
			LogInfo( "EMAP vcbEXPORT task 4: Existing snapshot of VM '" & sVMFQDN & "', VMID=" & sVmID & ", SSID=" & sSSID & " - deleted successfully." & vbCrLf & vbCrLf & sOutput)  
		End If
		WScript.Sleep 5000
	Else
		'// Log error and fail backup ..  
		LogError("EMAP vcbEXPORT task 4: ERROR: Existing VCB Snapshots found for VM: " & sVMFQDN & ", and 'CONTINUE_IF_VCB_SNAP_FOUND = False', so backup will not proceed. VCB BACKUP FAILED!" & vbCrLf & vbCrLf & sOutput)  
		Err.Clear
		WScript.Quit(1)
	End If
End If
sOutput = ""  
sSSID = ""  


'// ===============================================  
'// 5. Create snapshot of the vm specified by VmID  
'// ===============================================  
LogInfo( "EMAP vcbEXPORT task 5: Creating snapshot of VM '" & sVMFQDN & "' for vcbBackup.")  
sSSID = RunCommand(VCB_INSTALL_PATH & "\vcbSnapshot.exe -h " & HOST & " -u " & USERNAME & " -p " & PASSWORD & " -c " & sVmID & " " & SNAPSHOTNAME, "ssid",False)  
'//If (Len(Trim(sSSID)) < 10) Or (InStr(LCase(sOutput), "error") > 1 ) Then  
If Len(Trim(sSSID)) < 10  Then
	LogError("EMAP vcbEXPORT task 5: UNKNOWN ERROR: vcbSnapshot did not successfully snapshot the VM: " & sVMFQDN & ". VCB BACKUP FAILED!" & vbCrLf & vbCrLf & sOutput)  
	WScript.Quit(1)
Else
	LogInfo( "EMAP vcbEXPORT task 5: Snapshot of VM '" & sVMFQDN & "' created successfully. Snapshot ID: " & sSSID & vbCrLf & vbCrLf & sOutput	)  
End If
sOutput = ""  


'// ==================================================================  
'//  6. Get paths for source disks on SAN ready for vcbExport backup  
'// ==================================================================  

LogInfo( "EMAP vcbEXPORT task 6: Retreiving SAN paths for VM disk/s to be backed up for VM '" & sVMFQDN & "'")  

'// Get dictionary object holding paths of all disks in the snapshot ...  
'// NOTE that the "True" parameter at the end fo the following command instructs the "RunCommand" function  
'// to add all matches to a dictionary object/array (global variable "oDict"), rather than just returning a single string match  
sDisks = RunCommand(VCB_INSTALL_PATH & "\vcbSnapshot.exe -h " & HOST & " -u " & USERNAME & " -p " & PASSWORD & " -l " & sVmID & " " & sSSID, "scsi", True)  

'// ### Error wegen Certifikat HIE  
' HIE Prüfung auf SSL-Zertifikat einschalten  
oWshShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMware Consolidated Backup\VerifySSLCertificates",1,"REG_DWORD"  
If Err.Number <> 0 then
	LogError(" Fehler beim Ändern der Registry (VerifySSLCertificates) auf 1 " + VbCrLf + "oWshShell.RegWrite HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMware Consolidated Backup\VerifySSLCertificates,1,REG_DWORD")  
end if

If (InStr(LCase(sOutput), "error") > 0) Then  
	LogError("EMAP vcbEXPORT task 6: UNKNOWN ERROR: vcbSnapshot did not successfully list disks in : " & sSSID & " for VM: " & sVMFQDN & ". VCB BACKUP FAILED!" & vbCrLf & vbCrLf & sOutput)  
	WScript.Quit(1)
Else
	LogInfo( "EMAP vcbEXPORT task 6: Successfully listed disks in snapshot for VM '" & sVMFQDN & "' for snapshot " & sSSID & vbCrLf & vbCrLf & sOutput	)  
End If

sOutput = ""  
colKeys = oDict.Keys
'// ==================================================================  
'//  7. Then run vcbExport to export the disk file to the specified   
'//     mount point  
'// ==================================================================  
'// For each disk specified for backup on the commane line:  
For i = 0 To UBound(aDisksToBackUp)
	'// Check to see if the disk exists in the snapshot using "vcbSnapshot -l"  
	'// If it does, obtain the corresponding SAN path from the output of "vcbSnapShot -l"   
	'// by removing the "scsiX.X:" part of the string  
	'// The remaining portion of the string which is obtained is the correct   
	'// source-path path for the disk as it should be passed to the vcbExport command  
	bDiskCheck = False
	sDiskPath = ""  
	sDiskFile = ""  
	'// Get full path of disk in correct case ...  
	For Each sKey in oDict.Items
	    sDisk = Trim(oDict.Item(sKey))
	    If InStr(sDisk, aDisksToBackUp(i)) Then
	    	sDiskPath = Mid(sDisk,InStr(sDisk,":")+1, Len(sDisk)-InStr(sDisk,":"))  
	    	bDiskCheck = True
	    End If
	Next
	'// If SAN path for disk is returned successfully, run vcbExport for the disk:  
	If (bDiskCheck = True) And InStr(LCase(sDiskPath),(".vmdk")) Then  
		'// Try export  ###################################################################################  
		sDiskFile = Trim(Mid(sDiskPath,InStrRev(sDiskPath, "/")+1,Len(sDiskPath)-InStrRev(sDiskPath, "/")))  
		LogInfo( "EMAP vcbEXPORT task 7: Running vcbExport to backup disk '" & sDiskPath & "' for VM '" & sVMFQDN & "'")  
		sSnapNumber = Mid(sSSID,InStr(sSSID,":")+1, Len(sSSID)-InStr(sSSID,":"))  
		sPercentExportComplete = RunCommand(VCB_INSTALL_PATH & "\vcbExport.exe -M 1 -d " & chr(34) &BACKUPROOT & "\" & sVMFQDN & "-CustomDiskBackup\" & sDiskFile & CHR(34) & " -s " & Chr(34) & "blklst://" & sSnapNumber & sDiskPath & "@" & HOST & "?" & USERNAME & "/" & PASSWORD & Chr(34),"100%",False)  
		If (InStr(sPercentExportComplete, "100%") > 0) And (InStr(LCase(sOutput),"error") < 1) Then  
			'// Export ** should ** have worked ...  
			'// Check file size on disk to make sure ...  
			LogSuccess( "EMAP vcbEXPORT task 7: vcbExport of disk '" & sDiskPath & "' to path '" &  BACKUPROOT & "\" & sVMFQDN & "\" & sDiskFile & "', for VM '" & sVMFQDN & "' completed successfully!" & vbCrLf & vbCrLf & sOutput)  
		Else
			'// Export failed ....  
			LogError("EMAP vcbEXPORT task 7: ERROR: vcbExport of disk '" & sDiskPath & "' to path '" &  BACKUPROOT & "\" & sVMFQDN & "\" & sDiskFile & "', For VM '" & sVMFQDN & "' failed! VCB BACKUP FAILED for this disk!" & vbCrLf & vbCrLf & sOutput)  
		End If
	Else
		'// Fail backup for this disk - cannot proceed without correct source path of disk to backup  
		LogError("ERROR: " & sVMFQDN & "EMAP vcbEXPORT task 7: Unable to obtain source path on SAN for disk " & sDisk & ". This disk will NOT be backed up! VCB BACKUP FAILED for this disk!" & vbCrLf & vbCrLf & sOutput)  
	End If
	sOutput = ""  
Next
' HIE Prüfung auf SSL-Zertifikat wieder ausschalten  
oWshShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMware Consolidated Backup\VerifySSLCertificates",0,"REG_DWORD"  
If Err.Number <> 0 then
	LogError(" Fehler beim Ändern der Registry (VerifySSLCertificates) auf 0 " + VbCrLf + "oWshShell.RegWrite HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMware Consolidated Backup\VerifySSLCertificates,0,REG_DWORD")  
end if
'// For debug  
sOutput = ""  
'  
'//############################################################################################  


'// ==================================================================  
'//       8. Remove snapshot once disk export is complete  
'// ==================================================================  
WScript.Sleep 5000
LogInfo( "EMAP vcbEXPORT task 8: POST DISK EXPORT (vcbExport) CLEANUP: Removing snapshot of VM '" & sVMFQDN & "' for vcbBackup.")  
sSSID = RunCommand(VCB_INSTALL_PATH & "\vcbSnapshot.exe -h " & HOST & " -u " & USERNAME & " -p " & PASSWORD & " -d " & sVmID & " " & sSSID, "error",False)  
If InStr(LCase(sSnapDelete), "error") Then   
	LogError("EMAP vcbEXPORT task 8: ERROR: Cannot delete existing snapshot: " & sVMFQDN & ": " & sSSID & ". VCB BACKUP FAILED!" & vbCrLf & vbCrLf & sOutput)  
Else
	LogInfo( "EMAP vcbEXPORT task 8: POST DISK EXPORT (vcbExport) CLEANUP: Existing snapshot of VM '" & sVMFQDN & "', VMID=" & sVmID & ", SSID=" & sSSID & " - deleted successfully." & vbCrLf & vbCrLf & sOutput)  
End If


'// ======================  
'//    BACKUP COMPLETE  
'// ======================  
LogInfo( "EMAP vcbEXPORT: backup of VM '" & sVMFQDN & "' COMPLETE!")  


'// =====================  
'//       Clean up  
'// =====================  
Set oFSO = Nothing
Set oDict = Nothing
Set oWshShell = Nothing


'// ===========================  
'//          FUNCTIONS  
'// ===========================  
Function RunCommand(sPath, sSearchVal, bAddToDict)
	Dim sRetVal, oExecRun, sLineText, sStdErr
	LogCommand("*****RunCommand:" & sPath)  
	oWshShell.LogEvent EVT_INFO, sVMFQDN & ": Running command '" & sPath & "'"  
	Set oExecRun = oWshShell.Exec(sPath)
	If Err Then
		LogError("ERROR: Error executing command: '" & sPath & "'. " & Err.Number & "-" & Err.Description & ". VM: " & sVMFQDN & ". VCB BACKUP FAILED!")  
		WScript.Quit(1)
	End If
	On Error Goto 0
	Do While oExecRun.Status = 0
		WScript.Sleep 100
	Loop
	Do Until oExecRun.StdOut.AtEndOfStream
		sLineText = oExecRun.StdOut.ReadLine
		If InStr(LCase(sLineText), LCase(sSearchVal)) Then
			sRetVal = Trim(sLineText)
			If bAddToDict = True Then
				'// Add all matches to array (global dictionary object 'oDict')  
				oDict.Add sRetVal,sRetVal
			End If
		End If
		sOutput = sOutput & vbCrLf & sLineText
		sLineText = ""  
	Loop
	sStdErr = Trim(oExecRun.StdErr.ReadAll)
	If Len(Trim(sStdErr)) > 0 Then
		LogError("ERROR: Error returned running command '" & sPath & "' for VM: "& sVMFQDN & ". Error: " & sStdErr & ". Backup ** may ** have failed for this VM!")  
	End If
	LogInfo("******* Antwort:" & sRetVal)  
	Set oExecRun = Nothing
	RunCommand = sRetVal
End Function

Function LogCommand(sMsg)
' kein Eintrag in Evt-log wegen Passwort  
	Dim oShell
	sMsg = "INFO (+" & Dauer & " s):" & sMsg  
	Set oShell = CreateObject("WScript.Shell")  
	WScript.StdOut.WriteLine sMsg
	Set oShell = Nothing
End Function

Function LogError(sMsg)
	Dim oShell
	sMsg = "Error (+" & Dauer & " s):" & sMsg  
	Set oShell = CreateObject("WScript.Shell")  
	WScript.StdOut.WriteLine  sMsg
	oWshShell.LogEvent EVT_ERROR, sMsg
	Set oShell = Nothing
End Function

Function LogInfo(sMsg)
	Dim oShell
	sMsg = "INFO (+" & Dauer & " s):" & sMsg  
	Set oShell = CreateObject("WScript.Shell")  
	WScript.StdOut.WriteLine sMsg
	oWshShell.LogEvent EVT_INFO, sMsg
	Set oShell = Nothing
End Function

Function LogSuccess(sMsg)
	Dim oShell
	sMsg = "ERFOLG (+" & Dauer & " s):" & sMsg  
	Set oShell = CreateObject("WScript.Shell")  
	WScript.StdOut.WriteLine  sMsg
	oWshShell.LogEvent EVT_SUCCESS,sMsg
	Set oShell = Nothing
End Function

Function Dauer
	Dauer = DateDiff("s",start,Now())  
End Function
Passi1985
Passi1985 15.04.2009 um 18:26:07 Uhr
Goto Top
Danke für dein Script. Werds mal durchtesten und dann nochmal bescheid geben wie's läuft!

Gruß
Pascal
Dracul
Dracul 26.05.2009 um 18:28:19 Uhr
Goto Top
Hi Pascal

ich habe die neue Version incl. alles damit zusammenhängende dort geposted.

neu dabei ist daß die VMX* files jetzt auch gesichert werden

http://viops.vmware.com/home/message/2186

Gruß Dracul