Web-based applications probably have as many pros as they do cons. But two of the biggest cons are that 1) your data is on someone else’s server, and 2) it can be difficult (if not impossible) to back up that data when you need to. Or ever.
That’s especially true for web-based email. Sure, you can install a desktop email client like Mozilla Thunderbird and hook that into your web mail account. You get a backup, and a way to use your account from your desktop.
If you think that solution is a bit to cumbersome and you use Gmail, then you might want to give Gmvault a peek. A command line tool, it provides a quick and easy way of backing up messages and folders in Gmail.
Let’s take a closer look at Gmvault.
Downloading and installing
Gmvault is a cross-platform tool – it’s available for Windows, Mac OS, and Linux. Let’s confine ourselves to Linux, why don’t we? You can download either a binary installer or the Python source files.
I installed it using the Python source package. To do the installation, I extracted the files from the archive that I downloaded. Then, I cracked open a terminal window, navigated to the directory containing the installation files, and then typed:
sudo python setup.py install
After entering my password, the Gmvault script and its supporting files were installed. From there, I was ready to go.
Backing up your Gmail account
To do that, open a terminal window and run the following command:
gmvault sync YourAccount@gmail.com
Where YourAccount is your Gmail account name.
You’ll be asked to authorize your account. That just tells Gmail to give the Gmvault script access to your account.
From there, the script downloads everything in your Gmail account – all messages, and all folders. This can take a while, depending on how many messages you have saved. If you’re like most Gmail users, that’s a lot.
The files are stored in a folder in your home directory called gmvault_db. Don’t worry. It’s not an actual database. It’s just a directory with a bunch of subfolders, each containing information about the emails that you’ve downloaded. The folders are named after the months and years in which you received the messages – for example 2009–06 contains all the messages you received in June, 2009.
Individual emails are stored in a compressed file, with the .eml extension. That’s a widely-used format for storing email messages. If you want to view an email, you need to uncompress the file and then open the .eml file in a text editor.
The biggest problem you’ll run into is knowing which message is which. The compressed files don’t have very intuitive file names – they have names like 1247757563864116657.eml.gz.
But I don’t want to backup all of my messages!
Gmvault can selectively download messages using, among other things, the following criteria:
- A specific folder
- The email address of a sender
Let’s say you want to back up only the messages in a folder named Books. To do that, run the following command:
gmvault sync –type custom –gmail-req ‘in:Books’ ‘YourAccount@gmail.com’
On the other hand, you might only want to back up emails from your sister Karen. To do that, run the following command:
gmvault sync –type custom –gmail-req ‘from:Karen’ ‘YourAccount@gmail.com’
The script will look for messages with Karen in the From field and grab those.
Restoring your messages
Let’s assume that something happened to your Gmail account. Maybe it got wiped out in a solar flare. Maybe it got cracked and said cracker deleted all of your messages. Using Gmvault, you can restore what you’ve backed up. How? By running the following command:
restore -d ~/gmvault-db YourAccount@gmail.com
That restores everything. If you only want to restore the last two months’ worth of email, use this command instead:
restore –type quick -d ~/gmvault-db YourAccount@gmail.com
Gmvault is a quick and effective way of backing up and restoring the messages in your Gmail account. And if you decide you don’t want to use Gmail anymore, it’s a great way to archive your messages before closing your account.
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.