I had to recover someone’s calendars from an OwnCloud SQL dump. I will detail the steps I went through in this post.
Export CalDav calendar from SQL dump
To explore a large SQL file, here
my_database_dump.sql, it is easier to import it
as a new database rather than exploring the text file.
Here I am using PostgreSQL but it should also work with MySQL or MariaDB.
Identify calendars in database
Open a new database connection,
Now that the database is loaded, it is possible to execute SQL queries to locate the identifier
id of calendars we want to recover.
You can use a query like this one,
Extract CalDav files from database
With each calendar
id, you can now adapt and run this little script to extract
You might need to install
psycopg2 Python module.
If you want to identify as
postgres to the database, you might need to run this script as
Now you should have a collection of iCalendar files
You can concatenate all
.ics from a directory to generate a iCalendar
then import this calendar.
You can also directly open the WebDav folder with a file explorer and copy-paste these files.
For exemple, a GVFS browser (e.g. Nautilus, Thunar, Dolphin) supports a URI like
You will be able to find this URL in OwnCloud calendar app.
After that, your calendars should be restored!