I discovered that my backup was full, so I began investigating what was taking up so much space. Of course, pictures were a huge one, but surprisingly, my mail was also a huge one. Now, I get a lot of e-mail, but I also try to clean things out and I keep my attachments pretty well cleaned out as well. So, I was very surprised to see how big my Thunderbird folder was.Taking a look at the directory where Thunderbird is installed, I noticed a file called “global-messages-db.sqlite”. This was a very large file, and I also noticed there were multiple versions of it, adding up to about 16GB of space.
After some investigating, I discovered that the multiple versions were from times that I had migrated my e-mail program from one computer to another and it had created multiple versions of the file to reconcile differences and conflicts. Those old versions were so out of date by now that it was no problem to delete them (knowing that the conflicts had to have been resolved by now).
That still left the actual “global-messages-db.sqlite” file, which was still quite large, so I wanted to see why it was so big when I try to be pretty good about cleaning out old messages and I’m using IMAP, so messages I delete should really be gone from everywhere.
Looking through my folders, I saw that I have a folder called “All Mail” within my “[Gmail]” folders (my e-mail uses Gmail on the back-end, but is not a traditional Gmail address). This All Mail folder was huge and had copies of every message I have ever received, even ones I had deleted. I was puzzled why it would be saving copies of messages I had deleted. I dug around some more, and came across a support article on Gmail about deleting IMAP messages. Summed up, this article says that unless you are using the [Gmail]/Trash folder, your messages are not actually deleted from your mail account, only the label that places them in your e-mail program’s folder structure are deleted. So, even though I had been diligently deleting unwanted mail for years, I hadn’t actually gotten rid of anything.
In Thunderbird, I went into “Tools” and then “Account Settings”. I found the settings for my Gmail account, expanded them by clicking the arrow to the left of the account name so that it points down, and then clicked on “Server Settings”. About half-way down the page, there’s a section that starts “When I delete a message:” and has three options. My settings were set to “Move it to this folder:”, and it was set to the Thunderbird local Trash folder. I updated this to use [Gmail]/Trash, so that messages will actually be deleted out of All Mail when I empty the trash.
I still had to deal with the fact that messages that I had deleted were still in All Mail, and there were way too many messages (over 40,000 messages) to sort through and see which ones needed to be kept. So, what I did was to make a folder on another one of my e-mail accounts in Thunderbird and move all of my folders of messages to keep into that other e-mail account. Once all of my messages were safely stored on that separate e-mail account, I went in and deleted everything in the All Mail folder. I then moved all of my folders back.
The “global-messages-db.sqlite” file was still huge, though, so I tool a look at the Mozilla Support documents and found an article called “Rebuilding the Global Database” which contained exactly the information I needed to clean that out. It’s actually very easy. Close out Thunderbird (make sure it’s completely closed), and then delete the “global-messages-db.sqlite” file.
When you re-open Thunderbird, it will automatically reindex everything and recreate the “global-messages-db.sqlite” file. This can take a while, though, so I started the process and let it run overnight. If you are curious how the process is going, you can check its progress by going under “Tools” and clicking “Activity Manager”.