Backing up OpenVZ ploop snapshots

As I mentioned in an earlier post I have been using snapshots to back up my OpenVZ servers. At first I used a slightly modified version of the backup script found on the OpenVZ wiki to create backups, and that worked fine except for one missing feature: logging.

This seemed as good an opportunity as any to start learning some Python (which to my great embarrassment I have not used much before). The result is a small Python script OVZ-Backup that backs up all OpenVZ containers (or a subset of them) using ploop snapshots and rsync. If there are errors it logs them with syslog and (optionally) sends out error messages to a list of email addresses/users.

The script sends out email using the ‘mail’ command and can only send them to local users as is. My last HowTo explains how you can use postfix to forward user email to an external address and relay emails sent from local email clients without SMTP support through your email provider’s SMTP server. This would let you send error messages to any email address you want.

JaspXML uploaded to Github

The first small step in cleaning up my simulator is complete. The result is the JaspXML parser. A simple XML parser/iterator for Java, designed for reading data from large XML files without the memory cost of a DOM parser, or the complexity of a SAX/StAX parser.

It is based on code I wrote for a project during a university course several years back. I needed a way of reading data from XML files, and since I did not know how large these data files would be I used a StAX parser. But StAX parsers are a pain to work with so I hid it behind a more DOM like interface to make it easier to use. It was ugly, but it worked. I later reused and improved the parser during my master’s thesis, when I once again needed a simple way of parsing very large XML files.

JaspXML is based on that final version. I completely rewrote, reorganized, documented, and tested it. What was left is a small and simple XML iterator that can step through an XML document using three commands; next(), down() and up().


Steps forward one step and returns the next element at the current depth of the XML document.


Steps down to the children of the current element.


Steps back up to the parent of the current element.

An example application is provided that uses JaspXML to parse an XML document and prints out the contents of each element.