Attaching and detaching the virtual disks of a backup to a target virtual machine
The Data Protection for VMware command-line interface can be used to attach and detach the virtual disks of a backup to a target virtual machine in a virtualized environment.
About this task
Using the command-line interface, from a backup you can attach one or more specified virtual disks to a target virtual machine in your vSphere environment. You can also use the Tivoli® Storage FlashCopy® Manager for VMware GUI to attach virtual disks from a backup. This attachment is possible even if another virtual machine in the same backup is already attached to the same or another target virtual machine. You can attach a datastore to an ESX host even if a datastore in the same backup is already attached to another ESX host. Similarly, you can attach virtual machines that are contained in a vApp environment.
vminstanceuuid:sourcevminstanceuuid
A virtual machine template if present is registered on the ESX host with the name template_name_backupid. You can attach or detach a single virtual disk from a template back up to a virtual machine. However, it is not possible to attach or detach virtual disks from a template or virtual machine backup to a virtual machine template.
vmcli command >>-vmcli------ -f attach----------------------------------------> >-- -B--backupID--+--------------+---- -I--attachObjectListFile--->< '- -H--esxHost-'
Specify the target host with the -H option. If this option is not specified, the target host defaults to the auxiliary ESX host as specified by the AUXILIARY_ESX_HOST profile parameter.
The attachObjectListFile file specifies the virtual machine that contains the virtual disks to attach to the target virtual machine. The file contains one virtual machine identifier in each line, optionally specifying an alternative target virtual machine.
The -F parameter forces a detach operation even if the corresponding backup task is still running. The -I parameter specifies the detachObjectListFile file. All the attached disks for the virtual machine, which is specified in the detachObjectListFile file, are detached. If the virtual machine is registered on the ESX host, Tivoli Storage FlashCopy Manager for VMware unregisters the virtual machine.vmcli command >>-vmcli------ -f detach------+-----------------+---------------> '- -t--backupType-' >--+------------------------+--+---------------------------+--->< '- -B--backupID--+-----+-' '- -I--detachObjectListFile-' '- -F-'
Several virtual machines in the same backup can be attached to the same ESX host. To detach only the virtual disks in a specified virtual machine, you must include the virtual machine in the detachObjectListFile file in the detach command. The mounted datastore is not unmounted if any virtual disks in the datastore are still attached to a virtual machine on the ESX host.
Similarly, if a virtual machine is still registered the datastore is not unmounted. When the detach command detaches the last attached virtual disk in the datastore and no VM is registered, Tivoli Storage FlashCopy Manager for VMware automatically unmounts the datastore.
Procedure
To attach a backup on an ESX host to a target virtual machine, enter the following command:
Where:
- -B backupID
- Specifies the ID of the backup to be attached.
- -I attachObjectListFile
- Specifies the file that contains the list of disks in the backup
to attach to the VM. The attachObjectListFile has
the following requirements:
- The file contains one VM identifier per line, optionally specifying an alternative target VM.
- All the disks in a backup can be attached to an existing VM that is specified after the :: symbol.
- If no disks are specified, all the backup disks are attached to the specified VM.
- The specified disks in the backup are attached to the target VM and added to the VM configuration.
# vminstanceuuid:sourceVmInstanceUuid[::vminstanceuuid:targetVmInstanceUuid] # [diskkey:key1,key2,...] # attach all backed-up virtual disks of vm2InstanceUuid to the (same) # source VM vminstanceuuid:vm2InstanceUuid::vminstanceuuid:vm2InstanceUuid # attach all backed-up virtual disks of vm3InstanceUuid to vm4InstanceUuid vminstanceuuid:vm3InstanceUuid::vminstanceuuid:vm4InstanceUuid # attach the disks with the specified keys of vm3InstanceUuid to vm4InstanceUuid vminstanceuuid:vm3InstanceUuid::vminstanceuuid:vm4InstanceUui diskkey:2000,2001 # register the complete VM vm4InstanceUuid vminstanceuuid:vm4InstanceUuid
To detach the last mounted backup, enter the following command:
vmcli -f detach