Quantcast
Channel: virtuallyPeculiar
Viewing all articles
Browse latest Browse all 167

Restore Virtual Machine From Command Line Using mccli

$
0
0
If you have worked on vSphere Data Protection, you will know that you can perform a Restore of a virtual machine from the VDP GUI in the web client. If the VDP web client GUI is unavailable and when the vCenter is down, we utilize the Direct-Host (Emergency Restore) option. However, with emergency restore you get to restore the VMs only on the host where the VDP is residing by disassociating the VDP's ESXi host from vCenter.

Another, less known option is to restore virtual machines from the command line of the VDP appliance. I had to spend quite a while to get the right switches and verify with a couple of sources before I got this restore done successfully.

1. You will have to check if the client is registered to the VDP and get the domain of the client if it is registered. Both of these can be obtained from the below command:
# mccli client show --recursive=true

The command outputs:

0,23000,CLI command completed successfully.
Client                    Domain                                     Client Type
------------------------- ------------------------------------------ ------------------------------------
vdp.happycow.local        /clients                                   VMware Image Proxy with Guest Backup
Replication-DR            /vcenter-dr.happycow.local/VirtualMachines Virtual Machine
Test                      /vcenter-dr.happycow.local/VirtualMachines Virtual Machine
vcenter-dr.happycow.local /vcenter-dr.happycow.local                 vCenter

Here, I will be restoring the Client called Test and the Domain for this VM is vcenter-dr.happycow.local/VirtualMachines

2. The restored virtual machine will be residing on a datastore. Run the below command to see if the datastore you would like to restore this VM to is seen by the VDP appliance. 
# mccli vcenter show --name=/vcenter-fqdn --recursive --type=datastore

The sample command and output will be similar to:
root@vdp:~/#: mccli vcenter browse --name=/vcenter-dr.happycow.local --recursive --type=datastore

0,23000,CLI command completed successfully.
Name             Type      Accessible    Hosts                  Datacenter
------------------ -------- -------------- -------------------   ------------------
is-tse-d128-1  VMFS    Yes             10.109.10.128    /Datacenter-DR
exit15_ISOs    NFS       Yes            10.109.10.128    /Datacenter-DR

3. Verify if the Folder you would like to restore this VM to on the vCenter is visible to the VDP appliance. 
# mccli vcenter show --name=/vcenter-fqdn --recursive --type=container

The sample command and the output will be:
root@vdp:~/#: mccli vcenter browse --name=/vcenter-dr.happycow.local --recursive --type=container

0,23000,CLI command completed successfully.
Name    Location                   Protected Type
------- -------------------------- --------- ------
Restore /Datacenter-DR/vm/Restore/ No        Folder
FL      /Datacenter-DR/vm/FL/      No        Folder

4. List all the available backups for the client that you would like to restore:
# mccli backup show --name=/vcenter-fqdn/VirtualMachines/<client-name> --recursive=true

The sample command and output will be:
root@vdp:~/#: mccli backup show --name=/vcenter-dr.happycow.local/VirtualMachines/Test --recursive=true

0,23000,CLI command completed successfully.
Created                          LabelNum Size    Retention Hostname           Location
----------------------- -------- ------- --------- ------------------ --------
2017-01-01 20:08:01 IST   3        40.0 GB DWMY      vdp.happycow.local Local
2017-01-01 20:04:02 IST   2        40.0 GB DWMY      vdp.happycow.local Local
2016-12-31 02:24:21 IST   1        40.0 GB DWMY      vdp.happycow.local Local

Here, the LabelNum column tells the order of the backup. 1 means the first, 2 is for second and so on. LabelNum=3 is the latest backup for this client in my example. 
You will have to note down which labelNum you would like to restore your VM from. I will be choosing LabelNum=1

5. Identify Plugin to be used during the restore. The plugin IDs are contained in the below file:
# less /usr/local/avamar/lib/plugin_catalog.xml
And the plugin ID for Windows VM is 3016 and Linux VM is 1016

The below command will output this for you:
# grep -i 'plugin-entry pid-number="1016"\|plugin-entry pid-number="3016"' /usr/local/avamar/lib/plugin_catalog.xml
The output:
    <plugin-entry pid-number="1016" pid="vmimage" description="Linux VMware Image">
    <plugin-entry pid-number="3016" pid="vmimage" description="Windows VMware Image">

6. Restore the VM using the below command:
# mccli backup restore --name=/vcenter-fqdn/VirtualMachines/<client-name>  --labelnum=<which backup to be restored> --restore-vm-to=new --virtual-center-name=<your-vcenter-fqdn> --datacenter=<your-datacenter-name> --folder=<the folder to restore the vm> --dest-client-name=<name for restored VM> --esx-host-name=<name of esxi host where restored VM should reside> --datastore-name=<where VM file should reside> --plugin=<plugin number> 
The sample command and the output will be:

root@vdp:~/#: mccli backup restore --name=/vcenter-dr.happycow.local/VirtualMachines/Test --labelNum=1 --restore-vm-to=new --virtual-center-name=vcenter-dr.happycow.local --datacenter=Datacenter-DR --folder=Restore --dest-client-name=Restored --esx-host-name=10.109.10.128 --datastore-name=is-tse-d128-1 --plugin=3016

0,22312,client restore scheduled.
Attribute   Value
----------- ----------------------------------------------------------------------
client      /vcenter-dr.happycow.local/VirtualMachines/Test_UDLiusDGKgqWLzJxSiw2uw
activity-id 9148334304676709

7. Monitor the restore status from the GUI or the command line using:
# mccli activity show --active
The output:

0,23000,CLI command completed successfully.
ID               Status  Error Code Start Time           Elapsed     End Time             Type    Progress Bytes New Bytes Client   Domain
---------------- ------- ---------- -------------------- ----------- -------------------- ------- -------------- --------- -------- ------
9148334304676709 Running 0          2017-01-02 13:14 IST 00h:00m:18s 2017-01-03 13:14 IST Restore 0 bytes        0%        Restored //N/A

Once the restore is completed, verify if the VM is available in the right location. The restored VM will be powered off by default.


Viewing all articles
Browse latest Browse all 167

Trending Articles