Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download all my caldav and carddav data with one wget / curl?

Until now, I used Google Calender and do my personal backup with a daily wget of the public ".ics"Link.

Now I want to switch to a new Service who has only caldavaccess.

Is there a possibility to download all my caldav and carddav data with one wget / curl?

This downloaded data should give me the possibility to backup lost data.

Thanks in advance.

edit

I created a very simple php file which works in the way hmh explained. Don't know if this way works for different providers, but for mailbox.org, it works well.

You can find it here https://gist.github.com/ahemwe/a2eaae4d56ac85969cf2.

like image 304
amw Avatar asked Apr 12 '14 12:04

amw


2 Answers

Please be more specific, what is the new service/server you are using?

This is not specifically CalDAV, but most DAV servers still provide a way to grab all events/todos using a single GET. Usually by targeting the relevant collection with a GET, e.g. like either one of those:

curl -X GET -u login -H "Accept: text/calendar" https://myserver/joe/home/
curl -X GET -u login -H "Accept: text/calendar" https://myserver/joe/home.ics

In CalDAV/CardDAV you can grab the whole contents of a collection using a PROPFIND:

curl -X PROPFIND -u login -H "Content-Type: text/xml" -H "Depth: 1" \
  --data "<propfind xmlns='DAV:'><prop><calendar-data xmlns='urn:ietf:params:xml:ns:caldav'/></prop></propfind>" \
  https://myserver/joe/home/

Replace calendar-data with

<address-data xmlns="urn:ietf:params:xml:ns:carddav"/>

for CardDAV.

This will give you an XML entity which has the iCal/vCard contents embedded. To restore it, you would need to parse the XML and extract the data (not hard).

Note: Although plain standard, some servers reject that or just omit the content (lame! file bug reports ;-).

like image 111
hnh Avatar answered Oct 21 '22 06:10

hnh


I tried the accepted answer which did not work for me. With my CalDAV calendar provider I can, however, retrieve all calendar files using

wget -c -r -l 1 -nc --user='[myuser]' --password='[mypassword]' --accept=ics '[url]'

where [myuser] and [mypassword] are what you expect and [url] is the same URL as the one that you enter in your regular CalDAV software (as specified by your provider).

The command creates a directory containing all the ICS-files representing the calendar items. A similar command works for my addressbook.

like image 21
highsciguy Avatar answered Oct 21 '22 08:10

highsciguy