Email is in our everyday life. It’s the ultimate system that changed the way of our communication for good. We now send emails for almost endless reasons. That’s why it’s also necessary to take backups of your email in case you face the need of an old email. Opening the web browser, log into your email account surely takes time. You can use Thunderbird, but the profile is prone to get lost if you need to setup your OS. Learn how to backup Thunderbird profile.
For those on Linux, there’s a really awesome way to back up your complete email without following all those complicated GUI. Trust me, in this scenario, the CLI is hundred times friendlier than the GUI tools.
We’ll be using a tool named IMAP Grab. It’s available on any version of Linux distribution, but it doesn’t come up pre-installed. We’ll be downloading it from the GitHub.
We’ll be needing some apps and packages beforehand to run the tool perfectly. At first, check out your installed Python version.
If the result returns Python v2.3.3 or higher, you’re good to go. Otherwise, update your software.
Now, we’ll be needing another dependency called “getmail”. Let’s install it right away!
sudo apt install getmail
sudo zypper install getmail
sudo dnf install getmail
- Arch Linux
sudo pacman -S getmail
Downloading IMAP Grab
This part requires installing Git client on your system. Learn how to install Git on Linux.
Run these commands in the terminal –
git clone https://github.com/ralbear/IMAPbackup.git cd IMAPbackup
Using IMAP Grab
Before we start using IMAP Grab for backing up our email, we have to configure the system first. Run this command –
python imapgrab.py imapgrab.py -l -s imap.test.com -u [email protected] -p emailpassword
Replace with your own email & password. Change “imap.test.com” with the IMAP server address your email service uses. For example, Gmail uses “imap.gmail.com” Now, the result will show you all the available mailboxes to download.
Now, run these commands for backing up your entire email. Note that we’ll be creating a dedicated folder for the downloading.
mkdir ~/email-backups python imapgrab.py -d -v -M -f ~/email-backups -s imap.test.com -u [email protected] -p emailpassword -m "_ALL_"
Done! Your email is backed up!
If you want to turn the entire backup into one single file, run this command –
tar -jcvf email-backup.tar.bz2 email-backups
If you didn’t know, you can easily encrypt the compressed file. Learn how to encrypt files on Linux.