aboutsummaryrefslogtreecommitdiffstats
path: root/archivemail.sgml
blob: 593c88268f8fffe72240b80105a7d0a1e5fe7daf (plain)
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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [

<!ENTITY flock "<CiteRefEntry>
<RefEntryTitle><Command/flock/</RefEntryTitle>
<ManVolNum/2/</CiteRefEntry>">

<!ENTITY gzip "<CiteRefEntry>
<RefEntryTitle><Command/gzip/</RefEntryTitle>
<ManVolNum/1/</CiteRefEntry>">

<!ENTITY mutt "<CiteRefEntry>
<RefEntryTitle><Command/mutt/</RefEntryTitle>
<ManVolNum/1/</CiteRefEntry>">

<!ENTITY procmail "<CiteRefEntry>
<RefEntryTitle><Command/procmail/</RefEntryTitle>
<ManVolNum/1/</CiteRefEntry>">

<!ENTITY python "<CiteRefEntry>
<RefEntryTitle><Command/python/</RefEntryTitle>
<ManVolNum/1/</CiteRefEntry>">

<!ENTITY seteuid "<CiteRefEntry>
<RefEntryTitle><Command/seteuid/</RefEntryTitle>
<ManVolNum/2/</CiteRefEntry>">

<!ENTITY crontab "<CiteRefEntry>
<RefEntryTitle><Command/crontab/</RefEntryTitle>
<ManVolNum/5/</CiteRefEntry>">
]>

<RefEntry>

<DocInfo><Date>12 April 2002</Date></DocInfo>

<RefMeta>
<RefEntryTitle>archivemail</RefEntryTitle>
<ManVolNum>1</ManVolNum>
<RefMiscInfo>SP</RefMiscInfo>
</RefMeta>

<RefNameDiv>
<RefName>archivemail</RefName>
<RefPurpose>archive and compress your old email</RefPurpose>
</RefNameDiv>

<RefSynopsisDiv>
<CmdSynopsis>

<Command/archivemail/
<Arg><Option>options</Option></Arg>
<Arg choice=req rep=repeat><Replaceable/MAILBOX/</Arg>

</CmdSynopsis>
</RefSynopsisDiv>

<RefSect1>
<Title>Description</Title>

<Para>
<Command/archivemail/ is a tool written in &python; for archiving and
compressing old email in mailboxes. 
</Para>

<Para>
By default it will read the mailbox <Replaceable/MAILBOX/, moving messages
that are older that the specified number of days (180 by default) to a
<application/mbox/-format mailbox in the same directory that is compressed
with &gzip;.  
</Para>

<Para>
<Command/archivemail/ supports reading <application/Maildir/,
<application/MH/ and <application/mbox/-format mailboxes, but it will
always write archive files to <application/mbox/-format mailboxes that 
are compressed with &gzip;.
</Para>

<Para>
<Command/archivemail/ has some support for being run as the root user on
user mailboxes. When running as root, it will &seteuid; to the owner of the
mailbox it is reading, creating any archive files as that user. 
</Para>
</RefSect1>

<RefSect1>
<Title>Options</Title>

<VariableList>

<VarListEntry>
<Term>
    <Option>-d <Replaceable/NUM/, --days=<Replaceable/NUM/</Option>
</Term>
<ListItem><Para>Archive messages older than <Replaceable/NUM/ days.  
The default is 180. This option is incompatible with the
<Option/--date/ option below.
</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>-D <Replaceable/DATE/, --date=<Replaceable/DATE/</Option>
</Term>
<ListItem><Para>Archive messages older than <Replaceable/DATE/.
<Replaceable/DATE/ can be a date string in ISO format (eg '2002-04-23'), 
Internet format (eg '23 Apr 2002') or Internet format with full month names 
(eg '23 April 2002'). Two-digit years are not supported.
This option is incompatible with the <Option/--days/ option above.
</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>-o <Replaceable/PATH/, --output-dir=<Replaceable/PATH/</Option>
</Term>
<ListItem><Para>Use the directory name <Replaceable/PATH/ to store the
mailbox archives. The default is the same directory as the mailbox to be
read.
</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>-s <Replaceable/NAME/, --suffix=<Replaceable/NAME/</Option>
</Term>
<ListItem><Para>
Use the suffix <Replaceable/NAME/ to create the filename used for archives.  
The default is <filename>_archive</filename>. For example, if you
run <Command/archivemail/ on a mailbox called
<filename>exsouthrock</filename>, the archive will be created
with the filename <filename>exsouthrock_archive.gz</filename>.
</Para>

<Para>
<Replaceable/NAME/ is run through the &python; <application/time.strftime()/
function, which means that you can specify any of the following special
directives in <Replaceable/NAME/ to make archives named after the current
date:

<itemizedlist mark='none'>
    <listitem><para><option>%a</option> 
    Locale's abbreviated weekday name.</para></listitem>
    <listitem><para><option>%A</option> 
    Locale's full weekday name.</para></listitem>
    <listitem><para><option>%b</option> 
    Locale's abbreviated month name.</para></listitem>
    <listitem><para><option>%B</option> 
    Locale's full month name.</para></listitem>
    <listitem><para><option>%c</option> 
    Locale's appropriate date and time representation.</para></listitem>
    <listitem><para><option>%d</option> 
    Day of the month as a decimal number [01,31].</para></listitem>
    <listitem><para><option>%H</option> 
    Hour (24-hour clock) as a decimal number [00,23].</para></listitem>
    <listitem><para><option>%I</option> 
    Hour (12-hour clock) as a decimal number [01,12].</para></listitem>
    <listitem><para><option>%j</option> 
    Day of the year as a decimal number [001,366].</para></listitem>
    <listitem><para><option>%m</option> 
    Month as a decimal number [01,12].</para></listitem>
    <listitem><para><option>%M</option> 
    Minute as a decimal number [00,59].</para></listitem>
    <listitem><para><option>%p</option> 
    Locale's equivalent of either AM or PM.</para></listitem>
    <listitem><para><option>%S</option> 
    Second as a decimal number [00,61]. (1)</para></listitem>
    <listitem><para><option>%U</option> 
    Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.</para></listitem>
    <listitem><para><option>%w</option> 
    Weekday as a decimal number [0(Sunday),6].</para></listitem>
    <listitem><para><option>%W</option> 
    Week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.</para></listitem>
    <listitem><para><option>%x</option> 
    Locale's appropriate date representation.</para></listitem>
    <listitem><para><option>%X</option> 
    Locale's appropriate time representation.</para></listitem>
    <listitem><para><option>%y</option> 
    Year without century as a decimal number [00,99].</para></listitem>
    <listitem><para><option>%Y</option> 
    Year with century as a decimal number.</para></listitem>
    <listitem><para><option>%Z</option> 
    Time zone name (or by no characters if no time zone exists).</para></listitem>
    <listitem><para><option>%%</option> 
    A literal "%" character.</para></listitem>
</itemizedlist>

</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>-S <Replaceable/NUM/, --size=<Replaceable/NUM/</Option>
</Term>
<ListItem><Para>Only archive messages that are <Replaceable/NUM/ bytes or
greater.
</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>-n, --dry-run</Option>
</Term>
<ListItem><Para>
Don't write to any files -- just show what would have been done. This is
useful for testing to see how many messages would have been archived.
</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>-u, --preserve-unread</Option>
</Term>
<ListItem><Para>
Do not archive any messages that have not yet been read. <command/archivemail/
determines if a message in a <application/mbox/-format or
<application/MH/-format mailbox has been read by looking at the
<application/Status/ header (if it exists). If the status
header is equal to 'RO' or 'OR' then <application/archivemail/ assumes the
message has been read. <command/archivemail/ determines if a
<application/maildir/ message has
been read by looking at the filename. If the filename contains an 'S' after 
<filename>:2,</filename> then it assumes the message has been read.
</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>--delete</Option>
</Term>
<ListItem><Para>
Delete rather than archive old mail. Use this option with caution!
</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>--include-flagged</Option>
</Term>
<ListItem><Para>
Normally messages that are flagged important are not archived or deleted. If
you specify this option, these messages can be archived or deleted just like
any other message.
</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>--no-compress</Option>
</Term>
<ListItem><Para>
Do not compress any archives using &gzip;.
</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>--warn-duplicate</Option>
</Term>
<ListItem><Para>
Warn about duplicate <application/Message-ID/s that appear in the input
mailbox.</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>-v, --verbose</Option>
</Term>
<ListItem><Para>
Reports lots of extra debugging information about what is going on.
</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>-q, --quiet</Option>
</Term>
<ListItem><Para>
Turns on quiet mode. Do not print any statistics about how many messages were
archived. This should be used if you are running <Command/archivemail/ from
cron.
</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>-V, --version</Option>
</Term>
<ListItem><Para>
Display the version of <Command/archivemail/ and exit.
</Para></ListItem>
</VarListEntry>

<VarListEntry>
<Term>
    <Option>-h, --help</Option>
</Term>
<ListItem><Para>
Display brief summary information about how to run <Command/archivemail/.
</Para></ListItem>
</VarListEntry>
</VariableList>

</RefSect1>

<RefSect1>
<Title>Notes</Title>
<Para>
<Command/archivemail/ requires &python; version 2.0 or later.
</Para>

<Para>
When reading an <application/mbox/-format mailbox, <command/archivemail/ will
create a lockfile with the extension <filename>.lock</filename> so that
procmail will not deliver to the mailbox while it is being processed. It will
also create an advisory lock on the mailbox using &flock;.
<command/archivemail/ will also complain and abort if a 3rd-party modifies the
mailbox while it is being read.
</Para>

<Para>
<Command/archivemail/ will always attempt to preserve the mode,
last-access and last-modify times of the input mailbox. However, archive
mailboxes are always created with a mode of <application/0600/.
</Para>

<Para>
If <Command/archivemail/ finds a pre-existing archive mailbox it
will append rather than overwrite that archive.
</Para>

<Para>
<Command/archivemail/ attempts to find the delivery date of a message by
looking for valid dates in the following headers, in order of precedence: 
<application/Delivery-date/,
<application/Date/ and
<application/Resent-Date/.
If it cannot find any valid date in these headers, it
will use the last-modified file timestamp on <application/MH/ and
<application/Maildir/ format mailboxes, or the date on the 
<application/From/ line on <application/mbox/-format mailboxes.
</Para>

<Para>
<Command/archivemail/ will refuse to operate on mailboxes that are symbolic 
links or create tempfiles or archives in world-writable directories.
</Para>

</RefSect1>

<RefSect1>
<Title>Examples</Title>

<Para>
To archive all messages in the mailbox <filename>debian-user</filename> that
are older than 180 days to a compressed mailbox called
<filename>debian-user_archive.gz</filename> in the current directory: 
<screen>
<prompt>bash$ </prompt><userinput>archivemail debian-user</userinput>
</screen>
</Para>

<Para>
To archive all messages in the mailbox <filename>debian-user</filename> that
are older than 180 days to a compressed mailbox called
<filename>debian-user_April_2002.gz</filename> (where the current month and
year is April, 2002) in the current directory: 
<screen>
<prompt>bash$ </prompt><userinput>archivemail --suffix '_%B_%Y' debian-user</userinput>
</screen>
</Para>

<Para>
To archive all messages in the mailbox <filename>cm-melb</filename> that
are older than the first of January 2002 to a compressed mailbox called
<filename>cm-melb_archive.gz</filename> in the current directory: 
<screen>
<prompt>bash$ </prompt><userinput>archivemail --date'1 Jan 2002' cm-melb</userinput>
</screen>
</Para>

<Para>
Exactly the same as the above example, using an ISO date format instead:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --date=2002-01-01 cm-melb</userinput>
</screen>
</Para>

<Para>
To delete all messages in the mailbox <filename>spam</filename> that
are older than 30 days:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --delete --days=30 spam</userinput>
</screen>
</Para>

<Para>
To archive all read messages in the mailbox <filename>incoming</filename> that
are older than 180 days to a compressed mailbox called
<filename>incoming_archive.gz</filename> in the current directory: 
<screen>
<prompt>bash$ </prompt><userinput>archivemail --preserve-unread incoming</userinput>
</screen>
</Para>

<Para>
To archive all messages in the mailbox <filename>received</filename> that
are older than 180 days to an uncompressed mailbox called 
<filename>received_archive</filename> in the current directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --no-compress received</userinput>
</screen>
</Para>

<Para>
To archive all mailboxes in the directory <filename>$HOME/Mail</filename> 
that are older than 90 days to compressed mailboxes in the
<filename>$HOME/Mail/Archive</filename> directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail -d90 -o $HOME/Mail/Archive $HOME/Mail/*</userinput>
</screen>
</Para>

</RefSect1>

<RefSect1>
<Title>Tips</Title>
<Para>
Probably the best way to run <Command/archivemail/ is from your &crontab;
file, using the <Option>--quiet</Option> option.
</Para>

<Para>
Don't forget to try the <Option>--dry-run</Option> option for non-destructive
testing.
</Para>
</RefSect1>

<RefSect1>
<Title>Exit Status</Title>
<SimPara>Normally the exit status is 0. Nonzero indicates an unexpected error.
</SimPara>
</RefSect1>

<RefSect1>
<Title>Bugs</Title>
<SimPara>
There is no support yet for reading <application/MMDF/ or
<application/Babyl/-format mailboxes. In fact, <Command/archivemail/ will
probably think it is reading an <application/mbox/-format mailbox and cause
all sorts of problems.
</SimPara>

<SimPara>
<Command/archivemail/ is still too slow, but if you are running from &crontab;
you won't care. Archiving <application/maildir/-format mailboxes should be
a lot quicker than <application/mbox/-format mailboxes since it is less
painful for the original mailbox to be reconstructed after selective message 
removal.
</SimPara>
</RefSect1>

<RefSect1>
<Title>See Also</Title>
<SimpleList>
<Member> &python;, &gzip;, &mutt;, &procmail;</Member>
</SimpleList>
</RefSect1>

<RefSect1>
<Title>Url</Title>
<SimPara>The <Command/archivemail/ home page is currently hosted at 
<ulink type="http" url="http://archivemail.sourceforge.net">sourceforge</ulink>
</SimPara>
</RefSect1>

<RefSect1>
<Title>Author</Title>
<SimPara>Paul Rodger &lt;paul at paulrodger dot com&gt;</SimPara>
</RefSect1>

</RefEntry>