mleonhard / imapbackup Goto Github PK
View Code? Open in Web Editor NEWIMAP Backup Tool
Home Page: http://tamale.net/imapbackup/
License: BSD 3-Clause "New" or "Revised" License
IMAP Backup Tool
Home Page: http://tamale.net/imapbackup/
License: BSD 3-Clause "New" or "Revised" License
NOTE: This is an old version. imapbackup now lives at https://github.com/rcarmo/imapbackup . IMAP Backup Tool http://github.com/mleonhard/imapbackup http://tamale.net/imapbackup/ This program incrementally backs up IMAP folders to local mbox files. New messages are appended to the folder's mbox file. = Features = * Downloads all IMAP folders * Stores messages in mbox, mbox.gz, or mbox.bz2 * Each folder downloads to its own mbox file, eg. Inbox.Drafts.mbox * Downloads only new messages, appends them to the mbox file * IMAP4 SSL, supporting client and server certificates * Accesses IMAP account in read-only mode. Does not affect message 'seen' status. = Usage = Usage: imapbackup [OPTIONS] -s HOST -u USERNAME [-p PASSWORD] -a --append-to-mboxes Append new messages to mbox files. (default) -y --yes-overwrite-mboxes Overwite existing mbox files instead of appending. -n --compress=none Use one plain mbox file for each folder. (default) -z --compress=gzip Use mbox.gz files. Appending may be very slow. -b --compress=bzip2 Use mbox.bz2 files. Appending not supported: use -y. -f --=folder Specifify which folders use. Comma separated list. -e --ssl Use SSL. Port defaults to 993. -k KEY --key=KEY PEM private key file for SSL. Specify cert, too. -c CERT --cert=CERT PEM certificate chain for SSL. Specify key, too. Python's SSL module doesn't check the cert chain. -s HOST --server=HOST Address of server, port optional, eg. mail.com:143 -u USER --user=USER Username to log into server -p PASS --pass=PASS Prompts for password if not specified. NOTE: mbox files are created in the current working directory. = Example = $ python imapbackup.py -s shevek.tamale.net -u michael -e -f INBOX Password: Connecting to 'shevek.tamale.net' TCP port 993, SSL Logging in as 'michael' Finding Folders: 67 folders Folder INBOX: 1231 messages File INBOX.mbox / WARNING: Message #117 in INBOX.mbox has a malformed Message-Id header. File INBOX.mbox - WARNING: Message #269 in INBOX.mbox has a malformed Message-Id header. File INBOX.mbox - WARNING: Message #498 in INBOX.mbox has a malformed Message-Id header. File INBOX.mbox / WARNING: Message #609 in INBOX.mbox has a malformed Message-Id header. File INBOX.mbox | WARNING: Message #976 in INBOX.mbox has a malformed Message-Id header. File INBOX.mbox - WARNING: Message #1042 in INBOX.mbox has a malformed Message-Id header. File INBOX.mbox: 1230 messages Downloading 1 new messages to INBOX.mbox: 1.89 KB total, 1.89 KB for largest message Disconnecting $ = Compatibility = Python 2.5. May work on Python 2.4 with minor tweaks. = Changes = 2009-12-12 v1.4c * Use hashlib module instead of deprecated sha module - Ronan Sheth * Added --folders argument - Giuseppe Scrivano * imapbackup disappeared from Rui Carmo's site. This version found at: https://gist.github.com/raw/273418/fe7c59f69ba57c40dde8c8c33d6105f46f458df8/imapbackup.py 2008-12-08 v1.4b * Fetch with BODY.PEEK instead of BODY, to avoid marking Gmail messages as read - Brandon Long (Gmail team) 2007-05-28 v1.4a * SSL support! Can use a private key file and server certificate chain file. Unfortunately, Python's ssl module doesn't check the certificate chain. This needs to be fixed. * You can now specify the port number as part of the server name. Example: imapbackup.py -u user -s mail.com:1234 * Cleaned up code. Used pylint to find code that didn't comply with best practices. 2007-05-27 v1.3b * Fixed bug in error message printout. 2007-05-26 v1.3a * Better support for result of LIST command. Fixes the problem of some folders not getting backed up from Courier IMAPd * Improved usage printout, made parameters more consistent. * Added support for socket._fileobject.recv bugfix on Windows 2007-03-27 v1.2e * By Rui Carmo. Downloaded from: http://the.taoofmac.com/space/Projects/imapbackup http://web.archive.org/web/20071011040436/http://the.taoofmac.com/space/Projects/imapbackup
The original author is now on github and his repository is more up to date (version f)
Env: Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Error:
Connecting to '_' TCP port 143
Logging in as '_'
Finding Folders: 10 folders
Folder INBOX:
Traceback (most recent call last):
File "U:\Backup\IMAP\imapbackup.py", line 655, in
main()
File "U:\Backup\IMAP\imapbackup.py", line 560, in main
fol_messages = scan_folder(server, foldername)
File "U:\Backup\IMAP\imapbackup.py", line 232, in scan_folder
typ, data = server.fetch(num, '(BODY.PEEK[HEADER.FIELDS (MESSAGE-ID)])')
File "C:\Python27\lib\imaplib.py", line 443, in fetch
typ, dat = self._simple_command(name, message_set, message_parts)
File "C:\Python27\lib\imaplib.py", line 1070, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "C:\Python27\lib\imaplib.py", line 897, in _command_complete
typ, data = self._get_tagged_response(tag)
File "C:\Python27\lib\imaplib.py", line 999, in _get_tagged_response
self._get_response()
File "C:\Python27\lib\imaplib.py", line 961, in _get_response
data = self.read(size)
File "C:\Python27\lib\imaplib.py", line 235, in read
return self.file.read(size)
File "U:\Backup\IMAP\imapbackup.py", line 624, in _fixed_socket_read
buf_len = len(data)
TypeError: object of type 'cStringIO.StringO' has no len(
Solution:
#if 'Darwin' in platform.platform() and '2.3.5' == platform.python_version():
#socket._fileobject.read = _fixed_socket_read
#if 'Windows' in platform.platform():
#socket._fileobject.read = _fixed_socket_read
Profit:
Connecting to '_' TCP port 143
Logging in as '_'
Finding Folders: 10 folders
Folder INBOX: 4007 messages
File INBOX.mbox: not found
Downloading 4007 new messages to INBOX.mbox: 317.243 MB total, 17.201 MB for largest message
Folder INBOX.Ag&AOo-ncias: 6 messages
File INBOX.Ag&AOo-ncias.mbox: not found
Downloading 6 new messages to INBOX.Ag&AOo-ncias.mbox: 3.707 MB total, 2.447 MB for largest message
Folder INBOX.Curriculos: 0 messages
File INBOX.Curriculos.mbox: not found
New messages: 0
Folder Lixo Eletr&APQ-nico: 0 messages
File Lixo Eletr&APQ-nico.mbox: not found
New messages: 0
Folder Drafts: 0 messages
File Drafts.mbox: not found
New messages: 0
Folder Trash: 0 messages
File Trash.mbox: not found
New messages: 0
Folder Itens Exclu&AO0-dos: 930 messages
File Itens Exclu&AO0-dos.mbox: not found
Downloading 930 new messages to Itens Exclu&AO0-dos.mbox: 261.748 MB total, 12.767 MB for largest message
Folder Junk: 0 messages
File Junk.mbox: not found
New messages: 0
Folder Sent: 0 messages
File Sent.mbox: not found
New messages: 0
Folder Itens Enviados: 1554 messages
File Itens Enviados.mbox: not found
Downloading 1554 new messages to Itens Enviados.mbox: 159.940 MB total, 22.492 MB for largest message
Disconnecting
change this line to
#!/usr/bin/env python2,7
will make it work on gentoo linux, its not python 3 ready yet
I run the app: python imapbackup.py -s SERVER -u USER
And got this error:
Connecting to 'SERVER' TCP port 143
Logging in as USER
ERROR: command: LOGIN => unexpected response: 'NO cleartext logins disabled'
Any idea how to solve this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.