File: archmbox.1

package info (click to toggle)
archmbox 4.10.0-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 404 kB
  • sloc: perl: 986; sh: 400; makefile: 16
file content (422 lines) | stat: -rw-r--r-- 14,794 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
.TH "archmbox" "1" "" "" ""
.SH "NAME"
archmbox \- a simple email archiver
.SH "SYNOPSIS"
.LP 
archmbox [ \fB\-h\fR | \fB\-\-version\fR ]
.br 
archmbox \fBMODE\fR [ \fBOPTIONS\fR ]
\fB\-d\fR \fIdate\fR \fImailbox\fR [ \fImailbox\fR ... ]
.br 
archmbox \fBMODE\fR [ \fBOPTIONS\fR ]
\fB\-o\fR \fIdays\fR \fImailbox\fR [ \fImailbox\fR ... ]
.SH "DESCRIPTION"
.LP 
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.

.LP 
Four different \fBMODES\fR are available:

.IP \(bu
list mode, which is useful to list all selected messages before 
archmbox performs the real operations (archiving or deleting)
.IP \(bu
kill mode, if messages should be deleted from the mailbox(es) rather
than archived
.IP \(bu
archive mode, to archive the selected messages in a different mailbox
.IP \(bu
copy mode, to copy selected messages from a source mailbox(es) without modifying it

.LP 
Messages selection is based upon a date criteria; an absolute date or a
days offset can be specified.

.br 
It is also possible to refine the selection
using perl regular expressions on the header fields of the message. Keep in mind
to quote the so called metacharacters, which are reserved for use in perl's regex notation. The metacharacters are

    {}[]()^$.|*+?\\

.br 
All archived messages are stored in a new mailbox with the same name of
the original one + .archived as extension (this is the default, but can be
changed); the archive mailbox can be saved in gz or bz2 compressed format
as well.

.br 
Please note that the archive mailbox format is always mbox,
regardless of original mailbox format. Moreover, mailboxes must be specified using the full path.

.br 
Messages are appended to the archive mailbox to allow multiple executions
of the script against the same mailbox.
.SH "MODES"
.TP 
\fB\-a\fR, \fB\-\-archive\fR
Selected messages are archived in a different mailbox.

.TP 
\fB\-k\fR, \fB\-\-kill\fR
Selected messages are deleted rather than archived.

.TP 
\fB\-l\fR, \fB\-\-list\fR
List all selected messages.
.br 
Warnings about skipped mailboxes (in use, empty ...) are printed to stderr. So
redirecting them to /dev/null won't clutter your list.

.TP 
\fB\-y\fR, \fB\-\-copy\fR
Selected messages are copied from the source mailbox.
.SH "OPTIONS"
.LP 
.TP 
\fB\-b, \-\-backup\fR
Creates a backup of the original mailbox before archmbox execution.
The mailbox is called
\fImailbox.backup\fR

.TP 
\fB\-\-bzip2\fR
Use bzip2 to compress the archive mailbox (use with \-c).

.TP 
\fB\-c, \-\-compress\fR
Compress the archive mailbox after script execution.

.TP 
\fB\-d, \-\-date <date>\fR
Specifies the threshold date for messages. The date must be supplied in the
following format: yyyy\-mm\-dd

.TP 
\fB\-D, \-\-date\-header\fR
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.

.TP 
\fB\-e, \-\-extension <extension>\fR
Specifies the suffix for the archive mailbox; the default is \fIarchived\fR.
If \fInone\fR is specified, no suffix will be used (use carefully).

.TP 
\fB\-f, \-\-full\-name\fR
Prepends the path of the mailbox to the name of the archive mailbox. This option overrides \-n.

.TP 
\fB\-\-format\fR
Specifies the format of the mailboxes to parse. Legal values are mbox and mbx.
Defaults to "mbox".

.TP 
\fB\-h, \-\-help\fR
Prints help.

.TP 
\fB\-i, \-\-ignore <regexp>\fR
Any mailbox/directory matching <regexp> will be skipped while archiving.

.TP 
\fB\-\-keep\-flagged\fR
Flagged messages will not be archived.

.TP 
\fB\-\-keep\-unread\fR
Unread messages will not be archived.

.TP 
\fB\-m, \-\-minsize\fR
Specifies the minimum size of the mailbox to be archived. Mailboxes smaller than <minsize> will not be parsed for archiving.

.TP 
\fB\-n, \-\-archive\-name\fR
Specifies the name of the archive file (default: mailbox name)

.TP 
\fB\-\-nosymlink\fR
Do not follow symbolic links when processing mailboxes.

.TP 
\fB\-\-nowarnings\fR
Suppress mailbox related warnings. Use only if you know what you're doing!

.TP 
\fB\-\-omit\-prefix <prefix>\fR
Omit <prefix> from the name of the mailbox when full name (option \-f) is required.

.TP 
\fB\-o, \-\-offset <days>\fR
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.

.TP 
\fB\-p, \-\-archive\-path, \-\-path <directory>\fR
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.

.TP 
\fB\-r, \-\-reverse\fR
Reverse the sense of 
\fIoffset\fR or \fIdate\fR
value. It usually means 
\fIolder than\fR
but with this switch, it means
\fInewer than\fR.

.TP 
\fB\-R, \-\-recursive\fR
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.

.TP 
\fB\-t, \-\-tmpdir <directory>\fR
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'.
.br 
To see the default value used by archmbox, do: archmbox \-\-help.
.br 
<directory> must be specified using full path.

.TP 
\fB\-\-time <time>\fR
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.

.TP 
\fB\-\-totals\fR
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.

.TP 
\fB\-v, \-\-verbose\fR
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.

.TP 
\fB\-\-version\fR
Prints version number.

.TP 
\fB\-x, \-\-regexp <header=regexp>\fR
It is specified in form \-x field='regexp', where field can be any header. The \fIheader\fR part is case sensitive. The \fIregexp\fR part is case sensitive if the regexp contains at least one upper case letter, and case insensitive otherwise.
.br 
If message satisfies date range, but does not satisfy regexp match on  specified field, it won't be archived.
.br 
The option can be specified more than once; in this case, the message is
regexp matched against all the given rules, and if it satisfies
\fIany\fR, it will be archived.
.TP 
\fB\-X, \-\-Regexp <header=regexp>\fR
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.
.SH "CONFIGURATION"
.LP 
Archmbox is completely written in perl, but it uses some shell helpers to
perform its job (fuser, rm, gzip/gunzip etc.).
.LP 
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.
.LP 
All other relevant configuration options can be specified at installation time or at run time using the command line switches.

.SH "USAGE EXAMPLES"
.LP 
A complete example:
.LP 
\fBarchmbox \-a \-b \-c \-e 01 \-f \-d 2002\-01\-01 \-p ~/mail\-archive ~/Mail/personal\-stuff\fR
.LP 
This will archive all messages older than (received before...) Jan 1st 2002
from the 
\fIpersonal\-stuff\fR
mailbox in the Mail directory. Archive messages are
saved in a mailbox called 
\fIMail\-personal\-stuff.01.gz\fR
in the
\fI~/mail\-archive\fR
directory. After execution, you'll find a mailbox called
\fIpersonal\-stuff.backup\fR
in
\fI~/Mail\fR.
.LP 
Complex examples, using perl regular expressions:
.PP 
\fBarchmbox \-a \-o 1 \-\-keep\-flagged \-\-keep\-unread \\
.br 
   \-x From='(nagios|arpwatch|logcheck)@host\\.net' \\
.br 
   \-x Subject='^(Security Events|Syslog Summary|\\[SNORT\\])' \\
.br 
   ~/Mail/inbox\fR
.LP 
This will archive all \fIunflagged\fR, \fIread\fR messages older than 1 day where the sender
address matches \fInagios@host.net\fR, \fIarpwatch@host.net\fR or \fIlogcheck@host.net\fR
or whose subject field starts with either '\fISecurity Events\fR' or '\fISyslog Summary\fR'
or '\fI[SNORT]\fR' from the mailbox \fI~/Mail/inbox\fR. Messages will be saved in
\fIinbox.archive\fR in the \fIcurrent directory\fR where archmbox was started from.
.LP 
.PP 
\fBarchmbox \-\-archive \-\-offset 1 \-\-keep\-flagged \-\-keep\-unread \\
.br 
   \-\-Regexp From='@(host1|host2)\.example\\.com' \\
.br 
   \-\-regexp Subject='^(Security Events|Syslog Summary|\\[SNORT\\])' \\
.br 
   \-\-archive\-path ~/Mail/local\-network.archive \\
.br 
   \-\-archive\-name system\-msgs \\
.br 
   \-\-extension 'none' \\
.br 
   ~/Mail/inbox\fR
.LP 
This will archive all \fIunflagged\fR, \fIread\fR messages older than 1 day where the sender
address matches \fI@host1.example.com\fR or \fI@host2.example.com\fR and
whose subject field starts with either '\fISecurity Events\fR' or '\fISyslog Summary\fR'
or '\fI[SNORT]\fR' from the mailbox \fI~/Mail/inbox\fR. Messages will be
archived to the mbox \fIsystem\-msgs\fR in the directory
\fI~/Mail/local\-network.archive\fR.
.LP 
Some simpler examples:
.LP 
\fBarchmbox \-a \-o 15 ~/Mail/personal\-stuff\fR
.LP 
This will archive all messages older than 15 days in 
\fIpersonal\-stuff.archived\fR
(uncompressed mailbox).
.LP 
\fBarchmbox \-a \-r \-o 15 ~/Mail/personal\-stuff\fR
.LP 
The same as above, but only messages 
\fInewer\fR
than 15 days will be archived.
.LP 
\fBarchmbox \-k \-o 15 ~/Mail/personal\-stuff\fR
.LP 
This will delete all messages older than 15 days from 
\fIMail/personal\-stuff\fR
.LP 
\fBarchmbox \-a \-o 15 ~/Mail/* \-c\fR
.LP 
This will archive all messages older than 15 days in 
every mailbox found in
\fI~/Mail\fR.
All the archive mailboxes will be compressed.
.LP 
\fBarchmbox \-l \-r \-c /tmp/mbox \-o 20\fR
.LP 
List all messages in 
\fI/tmp/mbox\fR
which are newer than 20 days. 
Option \-c is meaningless (and so ignored...).
.LP 
\fBarchmbox \-l \-r \-c /tmp/mbox \-o 20 \-a \-\-bzip2\fR
.LP 
Same as above, but archiving is forced (\-a) and bzip2 is used for compression.
.LP 
\fBarchmbox \-a \-x Subject='archmbox' \-o 7 ~/mbox\fR
.LP 
Select for archiving all messages older than 7 days whose subject field
satisfies regexp match 
\fISubject =~ /archmbox/\fR
(\fISubject\fR is case sensitive, \fIarchmbox\fR is is case insensitive).
.LP 
\fBarchmbox \-l \-x Subject='archmbox' \-x From='fritz' \-o 7 ~/mbox\fR
.LP 
Select for archiving all messages older than 7 days whose subject field
contains 
\fIarchmbox\fR
\fBor\fR the sender is
\fIfritz\fR
(matches are case insensitive).
.LP 
\fBarchmbox \-l \-x Subject='archmbox' \-X From='fritz' \-o 7 ~/mbox\fR
.LP 
Select for archiving all messages older than 7 days whose subject field
contains 
\fIarchmbox\fR
\fBand\fR the sender is
\fIfritz\fR
(matches are case insensitive).
.LP 
\fBarchmbox \-a \-o 5 \-R /tmp/mbox ~/Mail\fR
.LP 
archmbox will archive all messages older than five days in
\fI/tmp/mbox\fR.
It then start parsing all mailboxes stored in
\fI~/Mail\fR
(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.
.LP 
\fBarchmbox \-a \-o \-1 ~/Mail/my_mbx_mailbox \-\-format mbx\fR
.LP 
archmbox archives all messages stored in
\fImy_mbx_mailbox\fR
and puts them into
\fImy_mbx_mailbox.archived\fR.
The source mailbox is a mbx mailbox (\-\-format mbx is used). The archive mailbox will be a mbox mailbox.
.SH "NOTES"
.LP 
When the script has to decide if a message needs to be selected from the
mailbox, it looks for the header 
\fIFrom\fR
generated by the mail server (this is
the first line of the message) and doesn't care about the date specified by the
sender's mail client. This is useful to avoid removing messages sent from
misconfigured mail clients.
This behavior can be changed by forcing the use of the "Date:" header (option \-D).
.LP 
Not all options are meaningful in all modes, ie compression is
meaningless in list or kill mode. If you specify a useless option for a
particular mode, archmbox simply ignores it.
.LP 
Archmbox uses a working directory to store temporary mailboxes. A default value for that directory is hard coded in the script, but can be changed during the configuration/installation process (see INSTALL for details).
It might happen that your mailboxes are too big for the partition holding this temporary directory, or you might want to perform archiving on too much mailboxes at the same time. In other words, you may run out of space.
Use the \-t option to specify a suitable working directory at runtime.
.LP 
If you see some differences in the mailbox's dimension (size/free space), keep in mind that your mailbox may contain a special message (512 bytes in size) with internal information related to the mailbox.
This message is meaningless for you, though archmbox recognizes it and lets you be aware of it. That message is left untouched in your source mailbox.
.LP 
A few words about locking. There has been a discussion about archmbox handles
file locking. The answer is simple: no mailbox is ever locked.
The reason behind this behavior is that I want archmbox to be as least invasive as possible, so other kind of checks are performed to ensure that no data is lost (mailbox has changed/mailbox is in use by another program). I will surely add some locking mechanism in the future.
.LP 
You don't need to execute archmbox as root... just take care to have write
permissions for the directories you use.
.SH "LINKS"
.LP 
Archmbox can be downloaded from:
.LP 
http://adc\-archmbox.sourceforge.net
.LP 
Archmbox is distributed under the terms of the \fBGPL\fR
.SH "AUTHOR(S)"
Copyright (C) 2001\-2005
.LP 
Alessandro Dotti Contra <adotti@users.sourceforge.net>
.LP 
Parts of the code were contributed by:
.LP 
Alex Aminoff, Brian Medley, Buck Holsinger, Davor Ocelic, Fabrice Noilhan, Jayanth Varma, Juergen Edner, Laurent Cheylus, Nicolas Ecarnot, Paco Regodon, Scott Thompson, Juergen Desher.
.LP 
The FreeBSD port is maintained by Talal Al\-Dik.
.br 
The OpenDarwin port is maintained by Markus Weissman.
.br 
The Debian package is maintained by Alberto Furia <straluna@email.it>
.SH "BUGS"
.LP 
Please report bugs to <adotti@users.sourceforge.net>
.SH "SEE ALSO"
.BR PERLREQUICK (1),
.BR PERLRETUT (1),
.BR PERLRE (1)