Can I restore individual iCal appointments using Time Machine?

I use Time Machine to backup my Mac. While it is very easy to restore files and folders, I can't do the same with appointments in iCal. I am trying to recover an entire calendar that was accidentally deleted.

Apple provides instructions on how to restore from manually exported iCal archives. It sort of defeats the purpose of Time Machine, where backups are created automatically. By contrast, Time Machine works directly in Address Book in Lion.

Does anyone know if there is a way to restore iCal appointments (or calendars) using Time Machine? I know I can probably restore the cryptic calendar files in the Library folder, but I want to find a better way.


Solution 1:

I asked staff at the Apple Store the same question, who consulted with a Genius. As of Mountain Lion, it is still not possible to go into Time Machine via iCal/Calendar. In other words, the only solution is to manually restore deleted entries from raw iCal/Calendar files (located in ~/Library) using Time Machine.

There is a related discussion on Apple Support Communities:

  • https://discussions.apple.com/thread/3851319?start=0&tstart=0

The person I spoke to also reminded me to turn off iCloud before attempting the restore procedure, as it may corrupt existing calendars.

Solution 2:

You can; it will involve some command line work (which I'll list but not explain here):

  • Quit iCal & Mail. Disconnect from the internet if any of your calendars are cloud-connected.
  • In Finder, open <home>/Library/Calendars/
  • Enter the Time Machine and go back to before the loss occurred. Identify the missing calendar.
  • Still in Time Machine, enter that calendar's folder. There is an Events folder here.
  • Restore the Events folder to your desktop (or somewhere else, but don't just "Restore" it back into the library).
  • Exit the Time Machine.
  • Open a terminal and go into the restored Events folder.
  • Concatenate all of the files (there's one per event) into one long events file named <whatever>.ics.
  • Open <whatever>.ics with your favorite editor and insert these 4 lines at the top of the file:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//iCal 4.0.4//EN
CALSCALE:GREGORIAN

and this line at the end of the file:

END:VCALENDAR

and save the file.

  • Open iCal and import this file into the new calendar, which should now contain your events.

Solution 3:

JRobert's procedure got me close today, but not all the way with Mavericks and iOS 8. It seems some formats have changed since that answer.

You need to grep out the lines he suggests adding. Each file creates them, and the resulting .ics file from simple concatenation will contain too many. I grepped most out verbatim, but used ^PRODID: because each calendar version (iCal, Mac OS X) used a different string.

When it was done, I used an editor to add a more modern PRODID at the beginning:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.9.4//EN
CALSCALE:GREGORIAN

At the beginning, and left the text to add at the end the same.

Finally, you need to reconnect to the Internet before you import. iCloud would delete the entries after I successfully imported them after reconnection. Keeping it connected convinced iCloud that they should be left in the calendar.

I still have no idea how the calendar was deleted. It happened a couple of days before the release of iOS 8, and it wasn't something I noticed happening.