(2021-05-20, randomchars42)

Recently needed to migrate my families' CalDAV / ICAL calendars from one server to the other. After exporting them to an .ics file I noticed they contained all the data from back when we started using digital calendars...

Do I need to import those into the new calendars on the new server? Not necessarily (although, it probably would not result in much of a performance impairment). So I decided to import only this year's data into the new calendar and keep the rest in an archival file.

But how?

A short search on the internet revealed not much to go with. I could send all my private calendar information to some website to convert it to .csv (at least the events, reminders, journal entries and todo-lists would be lost along the way), then filter by date and send the .csv to some other website to convert it back to .ics (which, in its terms, claims to keep all the data for improving the script). That sounded not so appealing.... In the end (underestimating, as always the effort needed) I wrote a small Python 3 tool to load calendar data, filter it by almost arbitrary constraints and write the data back to a file

The result: ICalTool


So I finally ended up:

  1. exporting the data to .ics
  2. running icaltool/run.sh /home/randomchars42/Calendar.ics -f "DTSTART:+2021" -o /home/randomchars42/Calendar-2021.ics to get this year's calendar
  3. importing it into the new server's calendar
  4. running icaltool/run.sh /home/randomchars42/Calendar.ics -f "DTSTART:-2021" -o /home/randomchars42/Calendar-archive.ics and storing the file some place safe for archival reas

Visit the project on GitHub: https://github.com/randomchars42/icaltool