Time Machine API?

Continuing the discussion from Do You Use It? Backup Strategies Span the Gamut:

Once upon a time, when Apple first announced Time Machine, I remember that they demonstrated the ability to do more than just view/recover files from the past.

The demo showed an app (I think it was Mail) with a Time Machine interface. You could activate TM while the app was running and it would show you the state of your mailbox(es) at various points in the past, allowing you to pull individual messages forward to the present.

Does anyone know if this feature still exists? Or if it ever existed?

I did a quick search for a Time Machine API, and I couldn’t find anything more than the properties used to configure the TM service.

Such an API would be awesome if it could be integrated with an app. For instance, suppose you have a spreadsheet open and you discover some kind of corruption. It would be great if you could, from within the app, view successively older versions of the sheet and then copy just a selected region of its cells to the present sheet. Maybe present the new and old ones side-by-side while you do this work.

I know that some office suites offer integrated versioning that can do this to various degrees, but if an app had a simple API to pull older versions of files, going as far back as a Time Machine volume has backups, I think it would greatly improve the user experience.

I don’t know that it was Mail – this does exist in other applications. If you’re in Contacts and select “Browse Time Machine Backups” from the Time Machine icon in the right menu bar, you see the Contacts window at prior points in time. But Mail.app no longer seems to support this; unsupported apps bring you the Time Machine interface viewing the current frontmost Finder window.

I don’t know that there is a list of applications that support this, other than knowing that Contacts does and Mail and Calendar don’t.

Dave

I think Mail and Contacts were the supported apps, but that feature went away some time ago.

1 Like

Interesting – so it LOOKS like it works in Contacts (in that the TM interface opens) but you can’t actually recover? That I would definitely call a bug.

Dave

I’ve done this in Numbers, though I’m not sure if I had to access the Time Machine backups. It may have relied on the version history stored in iCloud.

According to the page below, Apple says the same interface can access Time Machine backups.

With many apps, you can use File > Revert To > Browse All Versions to view previous versions of documents in Time Machine, then find and restore the version you want.

1 Like

With the advent of APFS, version history can be tracked by the file system, even without iCloud, and some Apple apps (including the iWork suite) have some amount of integration with versioning

But it’s never been clear to me about the retention history of this mechanism - does it keep every version saved? Every version auto-saved? Or is there a policy for retention and is that policy configurable? And are past versions backed up with TM (or anything else), or do backups only get the latest version, relying on your backup software to provide its own history?

Compared with Time Machine, where the retention policy is very clear: hourly for the past 24 hours, daily for the past week, and weekly until storage is completely filled.

1 Like

I think you are referring to Document Versions which are stored in the hidden and protected folder .DocumentRevisions-V100. This is separate from Time Machine. Howard Oakley has done some research into this and has an app “Revisionist” which explores document versions. See Between Undo and backups: document versions for some answers.

2 Likes

I remember this for Mail, and no, it doesn’t work anymore.

The concept was simple: if an application’s just showing you what’s in files in some folder(s), then to go back in time it just needs to look at Time Machine’s past version of that same folder.

I think it broke in Mail when Mail started being a lot more dependent on Spotlight. In the original Time Machine-enabled Mail you could use Mail’s normal search to find messages you wanted to restore. But that stopped working when Mail switched to using Spotlight for its search functionality. And I don’t think the Spotlight database is backed up by Time Machine.

By the way, it used to be that you were required to use the Time Machine UI to restore files. The Time Machine volume had security set to prevent you from just copying files out, unless you really knew what you were doing. I think it was via extended attributes.

I use this daily. Such a great feature.

Because the versions are tracked by the system if the app you’re using doesn’t support the feature you can use any other app that does. For text files I use CotEditor.

I’m a developer and whilst I use source control, restoring versions is still useful when I’m in between commits.

I just mentioned iCloud because that’s where my documents and their version history live. According to Apple’s support article, the versions in a Time Machine backup can also be part of a document’s version history, but I don’t think I’ve personally ever encountered this behavior.

My point was that if Apple’s article is accurate, it seems the feature you have imagined already exists in apps like Pages, Numbers, Keynote, and TextEdit.

I currently have a case where we lost one address in CONTACTS due to user error, TM can’t really help us and I’m a bit miffed that I wasn’t aware that TM can’t do this anymore, or only half way, yet unusable.

What should I use from now on to backup contacts properly?

iCloud Contacts sync to the cloud and going to icloud.com and data recovery you should be able to relieve the last backup from the cloud.

Alternatively, I would recommend using Automator or Shortcuts to grab all your contacts and export as a single vCard and save it with a date/time stamp to a file on disk that Time Machine then backs up. At least you can sift through the vCards to find the one that is lost or damaged somehow.

You can also manually export Contacts from File → Export → Contacts Archive. Double-click and you see this to restore the data from the archive.

image

Or Select all Contacts then File → Export → Export vCard and use a date code on the filename.

Set a reminder in Calendar or Reminders to periodically run these manual backup steps. Time Machine will back up the exported archive / vCard combined.

Because of the syncing via iCloud we lost the address in the first place. Delete by error on an iPhone and before you even realise, the iMac at home loses it as well.

I am grateful for any idea what to do in the future, but the suggested steps are unusable for the normal user (of this case) who never touched any kind of programming. A full replacement of the entire CONTACTS DB also would loose the changes made since such accidental deletion happened.

A user in the Contacts App on an iPhone deleted the address field of one of the contacts, it immediately sync’d to iCloud. Then an iMac received the sync as well. The system worked exactly as designed.

By the time anyone noticed, a bunch of other changes were made that you don’t want to lose if you were to restore from a previous backup.

Did you have a Time Machine drive attached to the iMac all the time? It would have been backing up every hour. Otherwise it snapshots to the internal disk until the backup drive is connected. When the next backup runs it copies all the snapshots over to the backup. The snapshots on the internal SSD are then cleared within 24 hours after the backup completes.

The idea is to not mess up your existing Contacts when you restore the contact missing the address that was deleted by accident. So what I am asking you to try is to create a new Mac user on your iMac. Then we make a best guess as to correct Time Machine backup of the AddressBook database that was made prior to when you think the contact address was deleted. Then you restore the Contact db (AddressBook folder) into the new empty user account. Open Contacts check the contact missing the address. If found, export it as a vCard, copy it back to your primary account. Switch back to your primary account. Then double-click it. It will ask if you wish to merge or something to that affect. Say Yes and there you go. Problem fixed.

Navigate Time Machine in Finder to ~/Library/Application Support/ and identify the backup that should be prior to when the address was deleted. Copy the AddressBook folder to /Users/Shared.

Then create a new user on your Mac and login to the new account. Do not setup iCloud nor enter your Apple ID if prompted. Copy the entire AddressBook folder in /Users/Shared to ~/Library/Application Support/ of this new user account. Then open Contacts.

Check the contact missing an address now has the address. If it does not. Go back to Time Machine and try another older backup date/time. Rinse and repeat till you find the contact that has the address intact. Then Export that one contact and save it to /Users/Shared. Switch back to your primary Mac user account. Double-click the vCard in /Users/Shared and voila! The contact should overwrite the existing one and the address will be restored. It may ask to merge or replace. I am not sure at the moment. But allow it to do so.

If you are prone to this scenario. It’s recommended to either automate the export of vCards or manually remember to export periodically. That will save you time should this happen again because it’s easy to restore a vCard you just double-click it.

Here’s an article to read about backing up Contacts.

Good luck!

1 Like