Calcardbackup: bash script to backup ownCloud calendars and addressbooks as *.ics/*.vcf files

I like to backup my ownCloud calendars and addressbooks as .ics/.vcf files, because it is very easy to restore: just import the backed up .ics/.vcf file to the server or a client and the accidentally deleted data is back online.

Therefore I initially wrote a bash script with hardcoded links for my installation. Two friends were interested and so I improved the script to be more generic which possibly makes it interesting for other users as well.

The script downloads all available calendars/addressbooks belonging to certain users from a ownCloud instance as .ics/.vcf files. Usernames and according passwords have to be given in a separate file. All downloaded files are then compressed to a single file with the current date in the filename.

It works with all ownCloud versions >= 5.0 (and Nextcloud as well) and has been tested under Debian Wheezy and Jessie. Of course shell access to the server is needed. Configuration is quite simple: in most cases the path to the ownCloud directory sufficient. It is not necessary to run the script with root privileges - in default configuration it only needs to have read access to ownClouds configuration file 'config.php'. At no point any data leaves the server.

If that sounds interesting to you, you are welcome to use it:

Best wishes,
Bernie_O

2 Likes

I just released version 0.2.0 of the script, which comes with a new option to include shared addressbooks/calendars to the backup. This may be used to provide only one username + password in the credentials-file to whom all addressbooks/calendars (to be backed up) are shared. A just for this purpose created new user would make sense. If the file gets somehow in wrong hands, only the credentials of this single user will be compromised.

Drawback of this approach is: added addressbooks/calendars will not be backed up, unless they are shared with that user. That's the price for improved security...

Have a look at the section "About the option -i / --include-shares" in the file README.md in the github-repo for a detailed "How to". There you can also find some usage examples:

Cheers, Bernie_O

1 Like

The new version of the script calcardbackup brings a big improvement regarding security: it does not need cleartext passwords or usernames of the ownCloud users anymore, because the script fetches all data directly from the database. Due to the fact that the data is not anymore retrieved via http(s) request from the ownCloud webinterface, it is now possible to backup calendars and addressbooks from broken ownCloud instances as long as the database is available!

1 Like

Is this portable between future versions of ownCloud? The layout of the db-tables might evolve.

If the table layout changes, the script will need to adapt.

1 Like

The repository moved to Codeberg. Find stable releases of calcardbackup here:

1 Like

calcardbackup v2.0.0 has been released. It comes with a new feature that might be interesting for some users who don’t have shell access to their ownCloud server:

:tada: With the help of the included PHP script calcardbackup_wrapper.php there is now a good chance to be able to run calcardbackup even without shell access. As I can’t test all hosters out there I am very interested in feedback about this.
Check out the section Can I use this without shell access to the server? in the README of the repository.

:checkered_flag: Apart from that, calcardbackup has been adapted to use temporary files and kernel caching instead of Bashs’ file descriptors. Thus the memory consumption is only a fraction of what it used to be. These measures give a massive performance boost and make the script run two to three times faster! :zap:

Edit: please note that the version at github is heavily outdated and lacks a lot of bugfixes and other improvements compared to the stable version at codeberg (find the link to the repo at codeberg here).

1 Like