I use iCloud for my calendars/contacts/reminders because it's just so convenient to share all the data instantly between all my devices, but I can't help worrying about what would happen if Apple's servers have a brain-fart. So I'd like to make my own backups. And, of course, I'd like those backups to happen completely automatically, with no human intervention at all, because I'm sure you all know that manual backups are backups that just stop happening.

Ideally the code for making these backups would run on the Linux machine that is responsible for all my other backups, and I'm happy to write the code to do this myself.

My question is ... can anyone point me at documentation for the protocols and APIs that Apple's applications use?