Backup Email with imap using NoPriv.py

Got got to rave about this little python script from Remy.

Feed it your mail server imap details along with the folder you want to back up, it will then do two cool things:

1. Back up your email to a maildir so that you can restore it if you need to
2. Create an html repository of all the emails you backed up, including attachments

There is no search, which can make it difficult to find what you need, but you can use CTRL+F in most browsers on the index page for the folder.

I modified the script slightly, so that I could feed the script a folder on the CLI, instead of editing the script. Just change this line:
###########################
# Do not edit above here #
###########################

IMAPSERVER = “”
IMAPLOGIN = “”
IMAPPASSWORD = “”
>>> IMAPFOLDER = [“”, “”, “”]

to

###########################
# Do not edit above here #
###########################

IMAPSERVER = “”
IMAPLOGIN = “”
IMAPPASSWORD = “”
IMAPFOLDER = [ sys.argv[1] ]

You would then type:

python nopriv.py myfolder

to initiate backup of myfolder.

This works great with Gmail, and you can backup multiple folders too.

Go here to get the script and see the documentation:

https://raymii.org/s/software/Nopriv.py.html

One thought on “Backup Email with imap using NoPriv.py

  1. Note: you may have to dig around a bit in the newly created folder and CTRL+h it view hidden files in order to find the maildir with the actual emails in it :)

Leave a Reply

Your email address will not be published. Required fields are marked *