owncloudrefers to the URL to the root of your ownCloud installation e.g.
useris your login and
passwordis your password. The URL to use is the same you use if you want to download the calendar or address book manually. In the upper, right corner of the Calendar and the Contacts app, there's a button named respectively Calendars and Address books. When you click on that, you get a dialog box with a list of your calendar(s) and address book(s). The screen shot below is from the Contacts app. To download manually push the button. Instead of doing that, right-click on it, and select "Copy link location" (or whatever your browser calls it) from the context menu. Your clipboard will now hold a URL looking something
owncloud/apps/contacts/export.php?bookid=1- for the calendar it would look like
owncloud/apps/calendar/export.php?calid=1. Make a simple script using those URLs:
#!/bin/bash DATE=`date +"%Y-%W"` # Download and gzip contacts. wget --auth-no-challenge --no-clobber --http-user=user --http-password=password \ -O $HOME/pimdata_backup/contacts-$DATE.vcf "owncloud/?app=contacts&getfile=export.php?bookid=1" gzip -f $HOME/pimdata_backup/contacts-$DATE.vcf # Download and gzip calendar. wget --auth-no-challenge --no-clobber --http-user=user --http-password=password \ -O $HOME/pimdata_backup/calendar-$DATE.ics "owncloud/?app=calendar&getfile=export.php?calid=1" gzip -f $HOME/pimdata_backup/calendar-$DATE.icsThe
--auth-no-challengeis to avoid having the server send an authentication challenge, which would mess up the download. The
--no-clobberis to avoid downloading a file that already exists. When gzipping the downloaded file it gets a
.gzextension appended to the filename, so it should normally not be an issue though. The backup files will now have names containing the year and week number like
calendar-2012-17.ics.gz. If you prefer to backup in another schedule than weekly, you will of course have to change the date command accordingly. Save the script somewhere preferably in your PATH - I use
~/binfor my scripts - and make it executable:
chmod u+x ~/bin/owncloud_backup.sh- or whatever you choose to call it. Test if the script works and set it up to run on a regular basis as a cron job or any other job scheduler; I use KAlarm because it's so damn easy to use 😉 You could use curl instead of wget, it's just a matter of preference. Update: As Klaus Muth mentions in a comment, it cannot be stressed enough that this method should not be used in a multi user environment as it places passwords in the process list at runtime.
Update 2 June 13 2012: I have updated the paths for ownCloud >= 4.3 (git master and stable4). HTTP Auth was broken in versions before that.