NAME
archmbox - a simple email archiverSYNOPSIS
archmbox [ -h | --version ]DESCRIPTION
Archmbox is a simple email archiver written in perl; it parses one or more mailboxes, select some or all messages and then perform specific actions on the selected messages.- •
- list mode, which is useful to list all selected messages before archmbox performs the real operations (archiving or deleting)
- •
- kill mode, if messages should be deleted from the mailbox(es) rather than archived
- •
- archive mode, to archive the selected messages in a different mailbox
- •
- copy mode, to copy selected messages from a source mailbox(es) without modifying it
{}[]()^$.|*+?\
MODES
- -a, --archive
- Selected messages are archived in a different mailbox.
- -k, --kill
- Selected messages are deleted rather than archived.
- -l, --list
- List all selected messages.
- -y, --copy
- Selected messages are copied from the source mailbox.
OPTIONS
- -b, --backup
- Creates a backup of the original mailbox before archmbox execution. The mailbox is called mailbox.backup
- --bzip2
- Use bzip2 to compress the archive mailbox (use with -c).
- -c, --compress
- Compress the archive mailbox after script execution.
- -d, --date <date>
- Specifies the threshold date for messages. The date must be supplied in the following format: yyyy-mm-dd
- -D, --date-header
- Force the use of the "Date:" header to age a message. If the header is somehow corrupt, the date/time information are gathered for the beginning line of the message.
- -e, --extension <extension>
- Specifies the suffix for the archive mailbox; the default is archived. If none is specified, no suffix will be used (use carefully).
- -f, --full-name
- Prepends the path of the mailbox to the name of the archive mailbox. This option overrides -n.
- --format
- Specifies the format of the mailboxes to parse. Legal values are mbox and mbx. Defaults to "mbox".
- -h, --help
- Prints help.
- -i, --ignore <regexp>
- Any mailbox/directory matching <regexp> will be skipped while archiving.
- --keep-flagged
- Flagged messages will not be archived.
- --keep-unread
- Unread messages will not be archived.
- -m, --minsize
- Specifies the minimum size of the mailbox to be archived. Mailboxes smaller than <minsize> will not be parsed for archiving.
- -n, --archive-name
- Specifies the name of the archive file (default: mailbox name)
- --nosymlink
- Do not follow symbolic links when processing mailboxes.
- --nowarnings
- Suppress mailbox related warnings. Use only if you know what you're doing!
- --omit-prefix <prefix>
- Omit <prefix> from the name of the mailbox when full name (option -f) is required.
- -o, --offset <days>
- Specifies the offset (in days) from today for threshold date of a message. This option replaces -d. If you specify -1, archmbox will operate on all messages.
- -p, --archive-path, --path <directory>
- Specifies where to store the archive mailbox (default: "."). <directory> must be specified using full path. The --path option is now deprecated and will be dropped in future releases.
- -r, --reverse
- Reverse the sense of offset or date value. It usually means older than but with this switch, it means newer than.
- -R, --recursive
- Act recursively on directories. If one or more directories are specified on the command line, all mailboxes stored in those directories will be parsed for archiving. Implies option -f.
- -t, --tmpdir <directory>
- Specify a temporary working directory. This value overrides
the default one, which will be set in descending order to the first
defined one of: the environment variables $TMPDIR and $TMP, the compiled
in one and, as a fallback, '/tmp'.
- --time <time>
- Use <time> in conjunction with <date> (option -d) to refine the threshold age for archiving. <time> must be specified in the following format: hh:mm:ss.
- --totals
- Prints an overall summary of the archiving operations. The summary contains the number of parsed and skipped mailboxes, the total number of messages parsed and saved, the total space used and saved.
- -v, --verbose
- Verbosity level. Default is 1 (line per message) in --list output. So, if set to 1 it only lists msgid, sender and subject. With -v=2, it also prints date.
- --version
- Prints version number.
- -x, --regexp <header=regexp>
- It is specified in form -x field='regexp', where field can
be any header. The header part is case sensitive. The regexp
part is case sensitive if the regexp contains at least one upper case
letter, and case insensitive otherwise.
- -X, --Regexp <header=regexp>
- Same as -x, --regexp except that for matching the regular expressions a logical 'and' mode is used for all regexp including the regexp given by -x, --regexp.
CONFIGURATION
Archmbox is completely written in perl, but it uses some shell helpers to perform its job (fuser, rm, gzip/gunzip etc.). The correct path for the helpers (both required and optional ones) is probed at installation time. If one required helper is missing the installation will not take place. If one optional helper is missing, the feature provided using that helper will be unavailable, but the script will be installed anyway. All other relevant configuration options can be specified at installation time or at run time using the command line switches.USAGE EXAMPLES
A complete example: archmbox -a -b -c -e 01 -f -d 2002-01-01 -p ~/mail-archive ~/Mail/personal-stuff This will archive all messages older than (received before...) Jan 1st 2002 from the personal-stuff mailbox in the Mail directory. Archive messages are saved in a mailbox called Mail-personal-stuff.01.gz in the ~/mail-archive directory. After execution, you'll find a mailbox called personal-stuff.backup in ~/Mail. Complex examples, using perl regular expressions: archmbox -a -o 1 --keep-flagged --keep-unread \-x From='(nagios|arpwatch|logcheck)@host\.net' \
-x Subject='^(Security Events|Syslog Summary|\[SNORT\])' \
~/Mail/inbox This will archive all unflagged, read messages older than 1 day where the sender address matches [email protected], [email protected] or [email protected] or whose subject field starts with either ' Security Events' or 'Syslog Summary' or ' [SNORT]' from the mailbox ~/Mail/inbox. Messages will be saved in inbox.archive in the current directory where archmbox was started from. archmbox --archive --offset 1 --keep-flagged --keep-unread \
--Regexp From='@(host1|host2).example\.com' \
--regexp Subject='^(Security Events|Syslog Summary|\[SNORT\])' \
--archive-path ~/Mail/local-network.archive \
--archive-name system-msgs \
--extension 'none' \
~/Mail/inbox This will archive all unflagged, read messages older than 1 day where the sender address matches @host1.example.com or @host2.example.com and whose subject field starts with either ' Security Events' or ' Syslog Summary' or ' [SNORT]' from the mailbox ~/Mail/inbox. Messages will be archived to the mbox system-msgs in the directory ~/Mail/local-network.archive. Some simpler examples: archmbox -a -o 15 ~/Mail/personal-stuff This will archive all messages older than 15 days in personal-stuff.archived (uncompressed mailbox). archmbox -a -r -o 15 ~/Mail/personal-stuff The same as above, but only messages newer than 15 days will be archived. archmbox -k -o 15 ~/Mail/personal-stuff This will delete all messages older than 15 days from Mail/personal-stuff archmbox -a -o 15 ~/Mail/* -c This will archive all messages older than 15 days in every mailbox found in ~/Mail. All the archive mailboxes will be compressed. archmbox -l -r -c /tmp/mbox -o 20 List all messages in /tmp/mbox which are newer than 20 days. Option -c is meaningless (and so ignored...). archmbox -l -r -c /tmp/mbox -o 20 -a --bzip2 Same as above, but archiving is forced (-a) and bzip2 is used for compression. archmbox -a -x Subject='archmbox' -o 7 ~/mbox Select for archiving all messages older than 7 days whose subject field satisfies regexp match Subject =~ /archmbox/ ( Subject is case sensitive, archmbox is is case insensitive). archmbox -l -x Subject='archmbox' -x From='fritz' -o 7 ~/mbox Select for archiving all messages older than 7 days whose subject field contains archmbox or the sender is fritz (matches are case insensitive). archmbox -l -x Subject='archmbox' -X From='fritz' -o 7 ~/mbox Select for archiving all messages older than 7 days whose subject field contains archmbox and the sender is fritz (matches are case insensitive). archmbox -a -o 5 -R /tmp/mbox ~/Mail archmbox will archive all messages older than five days in /tmp/mbox. It then start parsing all mailboxes stored in ~/Mail (recursion is active, and ~/Mail is a directory). If one or more directories will be found in ~/Mail, those directories will be explored as well. archmbox -a -o -1 ~/Mail/my_mbx_mailbox --format mbx archmbox archives all messages stored in my_mbx_mailbox and puts them into my_mbx_mailbox.archived. The source mailbox is a mbx mailbox (--format mbx is used). The archive mailbox will be a mbox mailbox.