Monday, January 5, 2009

Backup gmail and password protect it

Password Protect Files
---------------------
Confused with different programs which asks you to make private and public keys (e.g gnu-pg, pgp). Even worse, if you don't save the public and private keys generated by those programs and happen to reinstall the latest version of Linux which wiped out your home directory. For a greater security using such tools might be a requirement but for simple purposes you can use openssl with cipher encryption.

E.g You want to hide MyParty.jpg to iwillnottell.anything.

$ openssl enc -aes-256-cbc -salt -in MyParty.jpg -out iwillnottell.anything
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:


Once you enter the password and verify it you will get iwillnottell.anything. Now you can delete the original file MyParty.jpg. Later when you wan to retrive the file (You can even check it on another account to see if the password encryption program works at any installation):

$ openssl enc -d -aes-256-cbc -in iwillnottell.anything > ThisWasMyParty.jpg
enter aes-256-cbc decryption password:


Now we could password protect any file (you must remember what your password was, else you will end entering a wrong password and make Linux will cry(beep) and loose your file). Now we are ready to encrypt our gmail backup too.


Backup Gmail
------------

Install getmail
sudo apt-get install getmail4
mkdir ~/gmail-archive
touch ~/gmail-archive/gmail-backup.mbox
mkdir ~/.getmail
vi ~/.getmail/getmail.gmail
[retriever]
type = SimplePOP3SSLRetriever
server = pop.gmail.com
username = mymail@gmail.com
password = whatwasmypassword

[destination]
type = Mboxrd
path = ~/gmail-archive/gmail-backup.mbox

[options]
# print messages about each action (verbose = 2)
# Other options:
# 0 prints only warnings and errors
# 1 prints messages about retrieving and deleting messages only
verbose = 2
message_log = ~/.getmail/gmail.log

## Ends Here ##
################


I don't have to tell you have to enter your username and password above at specified places.

Enter this command to get your gmail to ~/gmail-archive/gmail-backup.mbox
$ getmail -r ~/.getmail/getmail.gmal


We enabled the verbose option, so you will see all the mail being downloaded. Once the download completes. You can backup the mail using above technique.

Read the mail
-------------

To read the mail, open evolution and use File->Import->Forward->Import a single file to browse and open gmail-backup.mbox to read all your mail from evolution.

Enjoy ...










No comments:

Post a Comment