A while back we wrote about backing up a Gmail account using Thunderbird. That doesn't work for restoring but you could at least have access to all your old emails.
'Backup Gmail' can backup / restore Gmail emails using a GUI or via command line
But I've recently discovered a small application that allows you to both backup and restore your Gmail emails in Linux with just a few clicks. The application is called "Backup Gmail" and you can use it to backup Gmail either from the command line or using a graphical user interface. It uses IMAP, meaning that restoring your emails will also restore their labels!
Incremental backups, preserve read / unread emails
Besides backup/restore, the also has a few other very useful features: it supports incremental backups and it can also preserve read/unread emails state - for this make sure you check the "Keep read/unread" option or else all your emails will be marked as read! However, using the "Keep read/unread" option, the Gmail backup becomes kind of slow.
Backup timetable, include / exclude labels
Further more, "Backup Gmail" can fetch only emails from a certain period of time and you can also include or exclude labels.
I've made two 'Backup Gmail' tests: one with a new account (which you'll see in the video below) in which everything worked perfectly and another one with a an account that has a few hundred emails. For this second account, Gmail Backup displayed an error when restoring my emails, however the restore actually worked; also, while backing up, the Backup Gmail window appeared to freeze but it was working so if that happens to you too, ignore it.
Not tested: the command line interface and the incremental backup option.
Not tested: the command line interface and the incremental backup option.
Backup Gmail video
Check out this video I've recorded demoing Backup Gmail (in the video you'll see both the backup and restore Gmail features in action):
Download and usage
Firstly, install the dependencies:
sudo apt-get install python-pyside.qtgui python-pyside.qtcore
To use 'Backup Gmail', download it from Launchpad (make sure you download the latest version), extract it and double click "gui.py", then select "Run". You can also set up automated backups using the command line interface - navigate to the folder where you've extracted Backup Gmail and run "./backup_gmail.py --help" to see all the available options. Basically all the features that are available for the GUI are also available in the command line interface.
Important: do not check the "Incremental Backup" option the first time you do a backup because you'll get an error like this: "username or password incorrect". You can check this option once you've performed the first backup.
Important: do not check the "Incremental Backup" option the first time you do a backup because you'll get an error like this: "username or password incorrect". You can check this option once you've performed the first backup.