8

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.

amw
  • 452
  • 1
  • 5
  • 14
  • I am not pretty sure, whether this helps! But please see the following link which may help you.. http://tanghus.net/2012/04/backup-owncloud-calendar-and-contacts/ – Praveen Vinny Apr 12 '14 at 13:17
  • Thanks a lot for reviewing and giving me that hint. But I only describes the download as ics-file. Not via caldav / carddav. – amw Apr 13 '14 at 13:17
  • 2
    You can use [vdirsyncer](https://github.com/untitaker/vdirsyncer) for this, although it's not exactly a "single wget/curl" command. – Markus Unterwaditzer Feb 12 '15 at 12:48

3 Answers3

17

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 ;-).

hnh
  • 13,957
  • 6
  • 30
  • 40
  • Thanks a lot, hnh. I will try your curl code as soon as I have some time. My Service is Mailbox.org. I will give some Feedback next week. – amw Apr 18 '14 at 12:27
  • I try to download my calendar from the webservice www.mailbox.org. – amw Apr 26 '14 at 15:33
  • The first idea doesn't work. I get nothing or "there is nothing here, sorry". The second idea seems to work. – amw Apr 26 '14 at 15:34
  • I get an XML with following structure: ...Link to ics file al lot of most empty tags If I do a GET request on the ics links, I get my calendar information. Hopefully, these files are sufficient to reimport the calendar. Did you mean this way? @hnh Thanks a lot. – amw Apr 26 '14 at 15:44
  • Asking for the 'calendar-data' property should give you the iCalendar right away in the response (no extra GET required). But yes, if that really doesn't work (file a bug with the vendor) - you need to do the PROPFIND to fetch the URLs and then either N GETs to retrieve the items (or a multi-get REPORT with 'calendar-data' property - if the server supports this). – hnh Apr 27 '14 at 17:21
1

Specifically for people using Baïkal (>= 0.3.3; other Sabre/dav-based solutions will be similar), you can go directly to

https://<Baïkal location>/html/dav.php/

in a browser and get an html interface that allows you to download ics files, and so also allows you to find the right links for those for use with curl/wget.

equaeghe
  • 1,644
  • 18
  • 37
  • 1
    I tried it and don't get a good result. The link is good but I could not download my data. Is there a newer possibility? – TravelTrader Apr 11 '19 at 15:23
  • To add some info here, if you click on "addressbooks/calendars" and then on the specific user you're interested in, the download options are hidden behind the red icons (book or calendar). – Lukas Knuth Dec 04 '22 at 23:11
1

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.

highsciguy
  • 2,569
  • 3
  • 34
  • 59