Skip to content

ralbear/IMAPbackup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backup remote IMAP server

After spending some time looking for a simple and reliable solution to backup a whole IMAP server, I have created this script to automate it from a comma separated files.

This script backup the whole messages and folders and returns a compressed file named as the user account user@domain.com.tar.gz, also including a log of the backup

Table of contents

Previous requirements

  • python 2.3.3 or later, python 3.* not supported
  • getmail

If you are running an Ubuntu/Debian system you can install this running:

$ sudo apt-get install python2 getmail4

Move to a work directory, clone this repository and change execution permission of the files

$ sudo chmod +x imapgrab.py run.sh

To test the connection with the server and list the folders for an account can do this

$ python2 imapgrab.py -l -s server.domain.com -S -p 993  -u username -p password

Comma separated data source

The file with the account´s details must look like this.

user1@domain.com,password1
user2@domain.com,password2

Customize server details

In the line 20 of run.sh file we can customize some details

$ python2 imapgrab.py -d -v -M -f $email -s server.domain.com -p 143 -u $email -p $pass -m "_ALL_,-INBOX.Trash,-INBOX.Spam" -L manager >> $email/backup_report.log

mbox or maildir

-M for maildir (default)

-B for mailbox

Server name

server.domain.com this is the name of the server

Port and SSL

-p 143 connection port

-S -p 993 add -S before port in case of a SSL connection

Skip some folders

-m "_ALL_,-INBOX.Trash,-INBOX.Spam" copy all the folders except INBOX.Trash and INBOX.Spam

Alternative user needed

-L manager if you run this script as root you need an alternative user to run imapgrab, in this case i have create manager user

References

About

IMAP backup script based in imapgrab

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published