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

Hi, this script looks to be exactly what im looking for. Ive tried to install but am having an issue. Ive got nextcloud and mariadb set up in docker using docker compose. When executing the script im getting an error on the host of the database, in my config.php this is set to “db” as both containers are running in the same stack. The db is mounted to my local volume though (i.e. outside of the container) so is there a way to set the path to the database in the script rather than reading it from the config file? Thanks in advance!

It is possible to create a dummy config.php outside the container with the required parameters and make calcardbackup to use that file instead the one from the container. See Does this also work with a broken instance in the repos’ README for more details.

Another approach might be Docker-Calcardbackup.
Here is a quote from the author waja which may help:

The examples there are based on hoellen/nextcloud (https://hub.docker.com/r/hoellen/nextcloud). You just need basically two things:
• path to nextcloud config
• database connection
This is not related to special images. official nextcloud image, linuxserver, hoellen, this does not matter much at all.

I have now been able to get calcardbackup running with my dockerized Nextcloud and MariaDB setup.

For this to work, it is important that the name of the database server (which is configured in nextcloud/config/config.php) is accessible by the host machine running calcardbackup. Therefore you can run this command to add all running containers to the /etc/hosts file:

docker inspect $(docker ps -q) --format='{{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}} {{ printf "%s" .Name}}' | awk {'print $(1), $(NF)'} | sed 's$/$$' >> /etc/hosts

Also, in my case, I had to install the Debian package mariadb-client to be able to send SQL requests to the Docker MariaDB.

Then I can successfully run
./calcardbackup /var/nextcloud/ -i

1 Like

@Bernie_O Thank you so much! With your script I was able to restore my family calendar.

Though I must admit, that I ran into a few roadbumps because I first forgot to set a version in the dummy config file and then missed the “oc_”-table prefix. But once I straightened out my mistakes it was a breeze. Excellent.

That would be such a cool option, to store ics-files directly in a user’s data directory, just like the notes… The database is a rather hostile environment after a crash.

1 Like