Restoring Gmail inbox from Time Machine

Time Machine backs up Gmail messages, but not in the right folders. How can I recover the folder structure?


I'm using the most current version of Yosemite.


  • I understand about Gmail tags, and how more than one tag can apply to a single Gmail message.
  • I understand that, because of this, Yosemite mail makes just one copy of the message, but figures out how to display messages properly in their folder(s).


  • I was working on Gmail directly on the web because I wanted to set up some filters. By mistake, I created a filter that moved all e-mail sent to my main address into the archive folder. This was OK because no messages were lost, and I usually sweep all my e-mail there (eventually) anyway.
  • However, I wanted to know which folders were in the inbox before I ran that filter. I had 50 or so e-mails over several months that still needed to be dealt with, and now they were irrecoverably (as far as Gmail was concerned) in my archive.
  • I had a time machine backup from a few hours earlier that was -- theoretically -- perfect for letting me know which e-mails were there before so I could deal with them. But, when I started Time Machine and went back a few hours or days in time the inbox was completely empty. I took the computer off line from internet, restored the whole Gmail account, but there were no e-mails in the inbox.
  • My iCloud and work (Exchange) account were fine; the inboxes there behaved normally.


How are you supposed to restore a Gmail setup to a previous state when this happens? I suppose I could have wiped my computer clean and then asked Time Machine to restore the whole computer to a prior state, but that seems a lot of work for a system that is supposed to allow you to go back in time for just a file or e-mail. Is there any solution using Time Machine?


I tried restoring the mailbox from a Backblaze snapshot from a few hours prior, but it was empty, just like he Time Machine backup.


I was able to recover the prior state because, luckily, I had made a Carbon Copy Cloner backup the night before. When I booted my Mac from the Carbon Copy Cloner bootable backup, it was slow to boot and run, but I was able to see the inbox as it was, export just the inbox, and make a note of which e-mails were there. However, I don't make Carbon Copy Cloner backups all that often (maybe every week or two), since my immediate backups should be in Time Machine and Backblaze.


Does anyone know how to restore a single Gmail folder -- or a whole Gmail account, but with e-mails in the right folders -- using Time Machine?


Thanks in advance for any assistance.

Posted on Jun 5, 2015 3:15 PM

Reply
27 replies

Jun 12, 2015 9:35 PM in response to Linda Custer

Also, I'm in Mail now, looking at the inbox of my Gmail account. Several messages there. I enter Time Machine (without going back in time at all -- just the opening screen) still pointing in the exact same place -- the inbox of the Gmail account, and there are no messages at all. It simply says


"Click restore to recover your inbox on Gmail"


That's all.


If I then browse to my other e-mail account inboxes, while still in the present time with Time Machine, there are plenty of inbox e-mails there.


Very, very strange.

Jun 12, 2015 9:36 PM in response to Linda Custer

Well I can't explain your gmail behavior. The INBOX is automatically mapped to Mail's inbox and that's how it shows on mine, but yours seems to be different. I don't know if there are any differences to a business gmail account. Maybe they are stored differently. Try clicking on the gmail label mailbox above the INBOX and see if there is an inbox folder there.

It still seems that when you enter TM while in Mail, it should bring up those messages.

Jun 12, 2015 9:55 PM in response to Linda Custer

OK. As I said, I'm not sure about the business gmail account, but I don't see why it would be different.


If you want to do a test, you could create a new user account to test with. Log into that account and put that gmail account in it. Then check it there.


You could also try rebuilding the account and index. Make sure you have a backup first.

Follow the steps to Repair and reindex messages in this article.

http://osxdaily.com/2013/08/01/rebuild-mailbox-reindex-messages-mail-mac-os-x/

In addition to removing the Envelope Index files, also trash the gmail account folder. Don't empty the trash in case you need to replace the files.

Quit Mail before removing the files. After moving the gmail folder and the Envelope Index files to the Trash, open Mail and let it reindex the messages. See if anything changes.


I'm going to bed, but I'll check tomorrow to see if you had any success. At the moment, I really don't have much more to add.

Jun 13, 2015 7:30 AM in response to Glenn Leblanc

Following the steps you mentioned solved my problem. Within Mail, I rebuilt the index by selecting Mailbox>Rebuild. Then I deleted all the Envelope Index files inside [user]>Library>Mail>V2>MailData. (I'm not sure the second step was necessary, but what the heck.)


The result: I can open Time Machine and see the files in the Gmail account's inbox. The individual e-mails are there and can be restored like any other account. Also, if I go to [user]>Library>Mail>V2>[Gmail account]>INBOX.mbox, there is a folder there as well as the info.plist file.


If I go back in Time Machine to points before I did this, the individual mailboxes do not show up, but they do going forward from this time.


So, I think the Rebuild action was key here.


I still don't understand why I had no trouble with day-to-day use of the Gmail account even though the [user]>Library>Mail>V2>[Gmail account]>INBOX.mbox folder only had info.plist, but mail was somehow smart enough to figure out which e-mails belonged there, even when the computer was offline. It was just blind to Time Machine. Of course, I don't need to know, but it's just troubling that I couldn't see the issue when using Mail normally, and it took a need to restore for me to see that I couldn't.


I'm glad I made that Carbon Copy Cloner backup when I did.


Thanks very much for your help.

Jun 13, 2015 10:53 AM in response to Linda Custer

Gmail does not use folders. It uses labels. Apple Mail does it's magic to make Gmail's non standard Labels work as folders.


Labels – Gmail’s labels are folders in an email client. Gmail can assign multiple labels to one message in your browser but these will be multiple messages in your email client.

All Mail contains a copy of every message in your Gmail account. The Inbox is just a label. If a message in All Mail does not have a label it has lost the "folder" in Mail.

Trash – Deleting a message in your browser will not delete the message. It simply moves it from Inbox to All Mail. To really delete, you have to move the message to the Trash.

Gmail works best in your browser because of it's non standard way of doing IMAP. You might like MailTabPro for Gmail $1.99. In Mac App Store (MAS). Nothing to download and easy access to your messages. Nothing to backup to Time Machine, but if you do make a mistake and delete items on the server there is no restore option.


https://itunes.apple.com/us/app/mailtab-pro-for-gmail/id430252530?mt=12&ign-mpt= uo%3D4

Jun 13, 2015 12:13 PM in response to dianeoforegon

Thanks.


As I mentioned in the first two bullets of my original posting, I am aware of Gmail's quirks about labels, and I do use it on the web when that makes sense. Using it on the web, though, is exactly what got me into this problem. I mistakenly used the web page to create a filter that moved my inbox e-mails into All Mail. There's no way on the web to go back to a prior state. (You can undo if you catch it immediately, but I didn't; I thought the filter was doing something else.)


So, using Apple's e-mail client is actually able to add value because (if the account files are not corrupted), Time Machine (or Backblaze or another backup strategy) can hold the e-mails as they were in the past.


It seems my Mac's e-mail files were corrupted. Now that I've rebuilt them, I've re-gained the ability to go back in time.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Restoring Gmail inbox from Time Machine

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.