Tuesday, August 2, 2016

How to Backup running Virtual Machine in XenServer

################  How to Backup running Virtual Machine in XenServer ###########

Xen server snapshot backup creation

1) mkdir /vm_backup
#mount -t nfs 192.168.10.212:/vol/vmimgbackup /vm_backup


2) List VM's (Steps to Manually Backup Running VM)

2.1)    Find VMs UUID
xe vm-list is-control-domain=false is-a-snapshot=false
uuid ( RO)           : 04eb7bf4-d5d1-e17f-cd73-90f469705c23
     name-label ( RW): CentOS_6_Noc_Test
    power-state ( RO): running

04eb7bf4-d5d1-e17f-cd73-90f469705c23 -- we get Server UUID


3) Create VMs Snapshot (Snapshot VM to template)
xe vm-snapshot uuid=04eb7bf4-d5d1-e17f-cd73-90f469705c23 new-name-label=Backup-test-Webserver-1-28JUN16

{Above command will retrun a UUID of snapshot, Use that UUID to convert snapshot to a vm, so we can export it to file using below command.}
426ef33c-24a2-252d-d4e3-cf012382ae66 -- Template UUID


4) Export template to standby VM - Backup NFS mount
xe template-param-set is-a-template=false ha-always-run=false uuid=426ef33c-24a2-252d-d4e3-cf012382ae66  ((Temlate on UUID ) )


5) Export Snapshot to file
xe vm-export vm=426ef33c-24a2-252d-d4e3-cf012382ae66 filename=/var/run/sr-mount/226ccade-c619-a32d-5ac0-116d66b8f505/bakcup/Backup-test-Webserver-1-28JUN16.xva

--------------------------------------------------------------------------------------------------------------
Import snapshot/create server from snapshot
xe vm-import filename=Backup-test-Webserver-1-28JUN16.xva

9c5e0951-ec6d-0e9a-ec22-0ad3c88ac525

Restart VM
xe vm-reset-powerstate uuid=9c5e0951-ec6d-0e9a-ec22-0ad3c88ac525 force=true

--------------------------------------------------------------------------------------------------------------
error resolved XenServer host CLI

Please execute "xe-toolstack-restart" command on the XenServer host CLI and let me know if it resolved the issue

--------------------------------------------------------------------------------------------------------------
################# 1.4. Destroy Snapshot ##############

{Finally as we have already taken backup to xva file, so we can destroy created snapshot from xenserver.}
xe snapshot-list  -----use for lost snapshot
xe host-list
xe sr-list

# xe vm-uninstall uuid=69616fa4-da57-947c-a8a7-aa043cf644ec force=true
384e54d6-fd6c-c041-90e8-f7db18aa89a5 ---------  1
8851d761-278d-5e4a-0ca1-43483c8b5aac ---------  2

Delete Snapshots
List VM's
xe vm-list is-control-domain=false is-a-snapshot=false

Delete Snapshots
xe vm-uninstall uuid=snapshot-name force=true
xe vm-uninstall uuid=9c5e0951-ec6d-0e9a-ec22-0ad3c88ac525 force=true

No comments:

Post a Comment