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.
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
- works on
.csv(both reading from and writing to)
- filters by date / range of dates (years, months, days), attendees, organizers, title ...
Python 3no other dependencies
So I finally ended up:
- exporting the data to
icaltool/run.sh /home/randomchars42/Calendar.ics -f "DTSTART:+2021" -o /home/randomchars42/Calendar-2021.icsto get this year's calendar
- importing it into the new server's calendar
icaltool/run.sh /home/randomchars42/Calendar.ics -f "DTSTART:-2021" -o /home/randomchars42/Calendar-archive.icsand storing the file some place safe for archival reas
Visit the project on GitHub: https://github.com/randomchars42/icaltool