Last active
June 16, 2016 17:15
-
-
Save fheinle/6434199 to your computer and use it in GitHub Desktop.
owncloud-backup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.