Changes

Jump to: navigation, search

stoney conductor: VM Backup

2,056 bytes added, 10:06, 10 January 2014
/* How to manually restore a machine from backup */
currentdate=`date --utc +'%Y%m%dT%H%M%SZ'`
mkdir -p /var/virtualization/retain/vm-persistent/${vmpool}/${machinename}/${currentdate}
cp -p /var/backup/virtualization/vm-persistent/${vmpool}/${machinename}/${backupdate}/* ${machinename}.xml.${backupdate}/var/virtualization/retain/vm-persistent/${vmpool}/${machinename}/${currentdate}/cp -p /var/backup/virtualization/vm-persistent/${vmpool}/${machinename}/${backupdate}/${machinename}.ldif.${backupdate}/var/virtualization/retain/vm-persistent/${vmpool}/${machinename}/${currentdate}/
</source>
domain="<DOMAIN>" # For example domain="stoney-cloud.org"
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,dc=stoney-cloud,dc=org${ldapbase}" -W "(objectclass=*)" > /tmp/${machinename}.ldif
diff -Naur /tmp/${machinename}.ldif /var/virtualization/retain/vm-persistent/${vmpool}/${machinename}/${currentdate}/${machinename}.ldif.${backupdate}
</source>
Remove the machine entry <code>dn=sstVirtualMachine=${machinename},ou=virtual machines,ou=virtualization,ou=services,${ldapbase}</code> from the LDAP directroy
<source lang='bash'>
echo "cat << EOF >> /tmp/remove_${machinename}.ldifdn=: sstVirtualMachine=${machinename},ou=virtual machines,ou=virtualization,ou=services,${ldapbase}"changetype: deleteEOFcat /tmp/remove_${machinename}.ldif
</source>
If everything looks OK, delete this entry
<source lang='bash'>
/usr/bin/ldapadd -H "ldaps://ldapm.${domain}" -x -D "cn=Manager,${ldapbase}" -W -f /tmp/remove_${machinename}.ldif
</source>
 
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/${vmpool}/${machinename}/${currentdate}/${machinename}.ldif.${backupdate}
</source>
 
Check the entry:
<source lang='bash'>
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=*)"
</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/${vmpool}/${machinename}/${backupdate}/${diskimage1}.${backupdate}
/var/virtualization/vm-persistent/${vmpool}/${diskimage1}
cp -p /var/backup/virtualization/vm-persistent/${vmpool}/${machinename}/${backupdate}/${diskimage2}.${backupdate}
/var/virtualization/vm-persistent/${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/${vmpool}/${machinename}/${backupdate}/${machinename}.state.${backupdate} --xml /var/virtualization/retain/vm-persistent/${vmpool}/${machinename}/${currentdate}/${machinename}.xml.${backupdate}
</source>
 
Now the machine should be up and running again. Continuing where it was stopped when taking the backup.
== Next steps ==
486
edits