Skip to main content

A doveadm wrapper for common archival tasks.

Project description

dovecot-archive is a doveadm wrapper for common mail archival tasks.

Usage

required arguments:

--user USER, -u USER

Source user whose mails will be moved.

optional arguments:

--folder FOLDER, -f FOLDER

Source folder which will be moved including its subfolders. If not given, all user’s folders will be moved

--dst-user DST_USER, -d DST_USER

Destination user to whom will the mails be moved. If not given, source user will be used.

--dst-root-folder DST_ROOT_FOLDER, -r DST_ROOT_FOLDER

Destination root folder to move the folder structure into, e.g. ‘Archive’. If not given, root namespace will be used.

--before BEFORE, -b BEFORE

Move only mails sent before this date. The date needs to supplied as unix timestamp, ISO-8601 (YYY-MM-DD), IMAP4rev1 (DD-Mon-YYYY) or a human readable representation of elapsed time (e.g. “2 months”, “3y”). If not given, all mails will be moved.

--since SINCE, --after SINCE, -a SINCE

Move only mails sent after this date. The date needs to supplied as unix timestamp, ISO-8601 (YYY-MM-DD), IMAP4rev1 (DD-Mon-YYYY) or a human readable representation of elapsed time (e.g. “2 months”, “3y”). If not given, all mails will be moved.

--split-by-year, -y

Create subfolders with the respective years in the destination folder structure as [/dst-root-folder]/<year>/<folder>/<subfolder>. If not given, folders will be moved as a whole.

--year-as-last-folder, -l

Create subfolders with the respective years as the last folder in the hierarchy as [/dst-root-folder]/<folder>/<subfolder>/<year>. Effective only when –split-by-year is used.

--copy, -c

Copy the mails instead of moving. If not given the mails are removed from the source location after successful move.

--namespace-separator, -s

Delimiter character used to separate Dovecot mailbox path components (i.e. not a filesystem directory separator).

--verbose, -v

Print informational (-v) and debug (-vv) messages. If not given, the tool is silent and outputs only fatal errors.

Use cases

Scenario 1)

I have way too many mails and it makes my e-mail client slow. I want to move sent and received mails older than 3 years to a different user/account (which I only open in my e-mail client when I really need to), and I want to retain the same folder structure of the mailboxes as I have under the current user/account. I don’t want to archive thrash, spam, etc.

Create a weekly cron task:

dovecot-archive --user original.user@example.com --dst-user archival.user@example.com --folder INBOX --folder Sent --before "3 years"

Scenario 2)

I have way too many mails and I want to move mails older than 14 days into an archive folder under the same user/account. I also want to create a subfolder for every year.

Create a daily cron task:

dovecot-archive --user user@example.com --folder INBOX --dst-root-folder Archive --split-by-year --before "14 days"

Scenario 3)

An employee is leaving the company and I want to move all their mail from 2020 onward to a new user/account of the employee replacing them. I want to move the whole folder structure, but to place it under a subfolder so it doesn’t interfere with the new employee’s mails.

Manually run once:

dovecot-archive --user leaver@example.com --dst-user joiner@example.com --dst-root-folder "Jane Doe" --since 2020-01-01

Changelog

1.2.0

  • Added --since parameter.

  • Updated datetime handling.

1.1.0

  • Added --namespace-separator parameter used to separate Dovecot mailbox path components.

1.0.1

  • Initial release.

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

dovecot_archive-1.2.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dovecot_archive-1.2.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file dovecot_archive-1.2.0.tar.gz.

File metadata

  • Download URL: dovecot_archive-1.2.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for dovecot_archive-1.2.0.tar.gz
Algorithm Hash digest
SHA256 a605eaa6db9bfcf9058803f0f6b03d1a2ccbf24905f51784c68f09b384f36bc8
MD5 116fbdba5cd8213dc87fef0a59e60d7f
BLAKE2b-256 0d3e966e17569b3873303370ea6910d4ea633973f0835645c0b0b7011ed7eb38

See more details on using hashes here.

File details

Details for the file dovecot_archive-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dovecot_archive-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 209af88906622a429e25330fafc0ff4afc48141f3ef1413a6f111a285b0d0ebe
MD5 b315e4243030e5e68858654e14aa83f7
BLAKE2b-256 99bdf56e8d5920c88a8f94a862da04626d493779031d36b78beca25535d43937

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