Skip to main content

No project description provided

Project description

imapbackup3

A Python package for creating full backups of IMAP mailboxes

Installation

python3 -m pip install --user imapbackup3

Command line usage

usage: imapbackup3 [-h] [-y] [-f FOLDERS] [-e] [-k KEY] [-c CERT] -s HOST
                   [-P PORT] -u USER [-p PASSWORD] [-t SECS] [--thunderbird]

Back up E-mail messages from an IMAP server. mbox files are created in the
current working directory.

optional arguments:
  -h, --help            show this help message and exit
  -y, --yes-overwrite-mboxes
                        Overwite existing mbox files instead of appending
  -f FOLDERS, --folders FOLDERS
                        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 (without port)
  -P PORT, --port PORT  Server port (defaults to 143 without and 993 with SSL)
  -u USER, --user USER  Username to log into server
  -p PASSWORD, --password PASSWORD
                        Prompts for password if not specified. If the first
                        character is '@', treat the rest as a path to a file
                        containing the password. Leading '' makes it literal.
  -t SECS, --timeout SECS
                        Sets socket timeout to SECS seconds.
  --thunderbird         Create Mozilla Thunderbird compatible mailbox

Python usage

Minimal example (using SSL on port 993):

from imapbackup3 import IMAPBackup
with IMAPBackup(host='mail.example.com', user='myuser', password='mypassword') as imb:
    imb.download_all_messages()

Full example:

from imapbackup3 import IMAPBackup
with IMAPBackup(
    host='mail.example.com',
    user='myuser',
    password='mypassword',
    port=993,
    usessl=True,
    keyfilename='my_key.pem',
    certfilename='my_cert.pem',
    thunderbird=False,
    folders=['INBOX', 'INBOX.Sent']
) as imb:
    imb.download_all_messages()

Background

This package is based on a script by Rui Carmo. Original description:

This was first published around 2007 (probably earlier) on my personal site, and it was originally developed to work around the then rather limited (ok, inconsistent) Mac OS X Mail.app functionality and allow me to back up my old mailboxes in a fully standard mbox format (well, at least as much as mbox can be considered a standard...).

Somewhat to my surprise it was considered useful by quite a few people throughout the years, and contributions started coming in. Given that there seems to be renewed interest in this as a systems administration tool, I'm posting the source code here and re-licensing it under the MIT license.

Features

  • ZERO dependencies.
  • Copies every single message from every single folder (or a subset of folders) in your IMAP server to your disk.
  • Does incremental copying (i.e., tries very hard to not copy messages twice).
  • Tries to do everything as safely as possible (only performs read operations on IMAP).
  • Generates mbox formatted files that can be imported into Mail.app (just choose "Other" on the import dialog).
  • Optionally compresses the result files on the fly (and can append to them).
  • Is completely and utterly free (distributed under the MIT license).

Requirements

This package requires Python 3.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imapbackup3-0.1.tar.gz (9.6 kB view details)

Uploaded Source

File details

Details for the file imapbackup3-0.1.tar.gz.

File metadata

  • Download URL: imapbackup3-0.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for imapbackup3-0.1.tar.gz
Algorithm Hash digest
SHA256 4b63d1c8df5b78607f7571615f9902dbf75bd08b143de966ab9521863843fbdf
MD5 dbc0b63878bd567b98ef950b0f4fa39e
BLAKE2b-256 6b460e2aaaa9b95b9b850f5d690e80a3024a6488259379d167edda345a4564cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page