Retrieve calendar data from database

Unfortunately i messed up my Nextcloud installation. I had to set up a new one.

The major problem now is that I lost the calendar data. Well, I didn’t completely lose it, it’s still in the database of the old installation.

I have access to the database and I was browsing through the calendar tables. But I was not ablel to find “human readable” entries so that I would be able to manually transfer the data.

However, what is the best way to extract the calendar data from the DB?

It would be of great help.

Thanks you!

Well… one could probably at least export the contents of teh calendars from the old database. There are four tables which are holding the calendars:

oc_calendars, which denotes all the calendars in the db. From there you will get the IDs, which you need to export the calendar entries from oc_calendarobjects, where there are the actual vevent objects.

In oc_calendarobjects, column ID and column calendardata should give you, what you want. Fire up some MySQL (or whatever DB you used to host the NC database) and use sql to extract your calendars into a txt file. Use that one to re-import your calendars back into your running NC instance.

1 Like

Thank you for your quick answer.

I got confused since i didn’t fine any “human readable” data in oc_calendarobjects, but till now I was not aware of the BLOB kinda type.

Now I got it. Thanks a lot!

I ran into the same issue and need to restore two calendars from a backup.
Would you mind assisting with some sql specific knowledge?
I figured out what I have to:

  1. start the backup database
    I could do this the dirty way and simply substitute the db files from the running NC instance like described here.

  2. Dump the required clendar tables
    What’s the syntax and how to find out which tables are the right ones?

  3. Restore and start the new (empty) db

  4. import the dump files
    mysql < dump.sql

You could use my script calcardbackup after firing up the old database to pull the two calendars from the old database and reimport them to the new installation. No need to fiddle around in the database then.

Have a look in the README of the repository for the section “does this work with a broken instance”.

1 Like

Thanks @Bernie_O!
I will definitely give your script a shot and come back with my report.

This script saved me.
Thank you very much :slight_smile:


If you mess up the password in the config file for any reason, you can type it in PLAIN TEXT if you remove the 'passwordsalt' line from the config.php file :wink: