Meet DAVup! It is a simple script that will back up any contacts, calendars and to-do lists synchronized through CardDAV or CalDAV.
I have always synchronized my contacts and calendars with online services to avoid losing them if something happened to my phone and to have them synchronized with my computer. For some time, I have been going a step further with my backups and have tried to keep a local backup of as many things as I can. With that goal in mind, I made DAVup, which is very simple and does exactly what I need. If you are interested, have a look!