Changes

Jump to: navigation, search

stoney conductor: VM Backup

4 bytes removed, 10:09, 10 January 2014
/* How to manually restore a machine from backup */
machinename="<MACHINE-NAME>" # For example: machinename="b6dc3d27-5981-4b18-8f3f-31ed3d21a3c6"
vmpool="<VM-POOL>" # For example vmpool="0f83f084-8080-413e-b558-b678e504836e"
vmtype="<VM-TYPE>" # For example vmtype="vm-persistent"
</source>
Change to the backup directory for the given machine and check the iterations:
<source lang='bash'>
cd /var/backup/virtualization/vm-persistent${vmtype}/${vmpool}/${machinename}
ls -al
</source>
<source lang='bash'>
currentdate=`date --utc +'%Y%m%dT%H%M%SZ'`
mkdir -p /var/virtualization/retain/vm-persistent${vmtype}/${vmpool}/${machinename}/${currentdate}cp -p /var/backup/virtualization/vm-persistent${vmtype}/${vmpool}/${machinename}/${backupdate}/${machinename}.xml.${backupdate}/var/virtualization/retain/vm-persistent${vmtype}/${vmpool}/${machinename}/${currentdate}/cp -p /var/backup/virtualization/vm-persistent${vmtype}/${vmpool}/${machinename}/${backupdate}/${machinename}.ldif.${backupdate}/var/virtualization/retain/vm-persistent${vmtype}/${vmpool}/${machinename}/${currentdate}/
</source>
Check if there is a difference between the current XML file and the one from the backup
<source lang='bash'>
diff -Naur /etc/libvirt/qemu/${machinename}.xml /var/virtualization/retain/vm-persistent${vmtype}/${vmpool}/${machinename}/${currentdate}/${machinename}.xml.${backupdate}
</source>
and '''edit the file at the retain location''' according to your needs.
ldapbase="<LDAPBASE>" # For expample ldapbase="dc=stoney-cloud,dc=org"
ldapsearch -H ldaps://ldapm.${domain} -b "sstVirtualMachine=${machinename},ou=virtual machines,ou=virtualization,ou=services,${ldapbase}" -s sub -x -D "cn=Manager,${ldapbase}" -W "(objectclass=*)" > /tmp/${machinename}.ldif
diff -Naur /tmp/${machinename}.ldif /var/virtualization/retain/vm-persistent${vmtype}/${vmpool}/${machinename}/${currentdate}/${machinename}.ldif.${backupdate}
</source>
and '''edit the file at the retain location''' according to your needs.
Add the LDIF from the backup (which you might have modified) to the LDAP directroy
<source lang='bash'>
/usr/bin/ldapadd -H "ldaps://ldapm.${domain}" -x -D "cn=Manager,${ldapbase}" -W -f /var/virtualization/retain/vm-persistent${vmtype}/${vmpool}/${machinename}/${currentdate}/${machinename}.ldif.${backupdate}
</source>
Copy all the disk images from the backup location back to their original location
<source lang='bash'>
cp -p /var/backup/virtualization/vm-persistent${vmtype}/${vmpool}/${machinename}/${backupdate}/${diskimage1}.${backupdate}/var/virtualization/vm-persistent${vmtype}/${vmpool}/${diskimage1}cp -p /var/backup/virtualization/vm-persistent${vmtype}/${vmpool}/${machinename}/${backupdate}/${diskimage2}.${backupdate}/var/virtualization/vm-persistent${vmtype}/${vmpool}/${diskimage2}
...
</source>
And restore the domain from the state file from the backup location with the XML from the retain location (the one you might have edited)
<source lang='bash'>
virsh restore /var/backup/virtualization/vm-persistent${vmtype}/${vmpool}/${machinename}/${backupdate}/${machinename}.state.${backupdate} --xml /var/virtualization/retain/vm-persistent${vmtype}/${vmpool}/${machinename}/${currentdate}/${machinename}.xml.${backupdate}
</source>
486
edits