Skip to content

Instantly share code, notes, and snippets.

@fheinle
Last active June 16, 2016 17:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fheinle/6434199 to your computer and use it in GitHub Desktop.
Save fheinle/6434199 to your computer and use it in GitHub Desktop.
owncloud-backup.sh
#!/bin/bash
# Configuration
# Backups will look like
# $BACKUPDEST/{calendar,contacts}_$CALENDAR_ID-$DATE.{vcf,ics}
DATE=`date +"%y-%m-%d_%H%M"`
BACKUPDEST=/some/path
# Enter your credentials here
HTTPUSER=florian
# you COULD store your password in plaintext here but that would be stupid
# try my small python script to use your OS's encrypted keyring instead
# (tested with GNOME-Keyring)
# https://github.com/fheinle/mutt/blob/master/scripts/kr.py
HTTPPASS=`/home/florian/.mutt/scripts/kr.py get florian@owncloud`
HTTPHOST=https://your-owncloud/installation/
ADDRESS_BOOKS="kontakte"
CALENDAR_IDS="default work fun"
for ADDRESS_BOOK in `echo $ADDRESS_BOOKS`;
do
CONTACTSFILE=$BACKUPDEST/contacts_$ADDRESS_BOOK-$DATE.vcf
wget --auth-no-challenge --no-clobber \
--http-user=$HTTPUSER --http-password=$HTTPPASS \
-O $CONTACTSFILE \
"$HTTPHOST/remote.php/dav/addressbooks/users/$HTTPUSER/$ADDRESS_BOOK/?export"
gzip $CONTACTSFILE
done
for CALENDAR_ID in `echo $CALENDAR_IDS`;
do
CALENDARFILE=$BACKUPDEST/calendar_$CALENDAR_ID-$DATE.ics
wget --auth-no-challenge --no-clobber \
--http-user=$HTTPUSER --http-password=$HTTPPASS \
-O $CALENDARFILE \
"$HTTPHOST/remote.php/dav/calendars/$HTTPUSER/$CALENDAR_ID?export"
gzip $CALENDARFILE
done
@wehkah
Copy link

wehkah commented Jun 16, 2016

In OwnCloud 9 the wget need to be modified: there has to be a slash "/" between the calendar's name and the argument "?export". The complete URL has to look like this:

"$HTTPHOST/remote.php/dav/calendars/$HTTPUSER/$CALENDAR_ID/?export"

It took me several hours to find that solution, so I'd like to save others from this frustration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment