Exists official ready-to-use version of script to create and restore Windows* templates:
http://wiki.solusvm.com/index.php/Xen_HVM_Templates
As stated below, FTP backup/restore solution of Xen HVM VPS also is ready. So, it can be used to achieve the same aim as Windows* template create/restore script for other operating systems:
http://wiki.solusvm.com/index.php/Automated_Backups