procmail
[Top] [All Lists]

Re: Mail backup

1997-08-13 14:28:00
On Wed, 13 Aug 1997, era eriksson wrote:

Uh-oh. Double-plus ungood :-)

Yeah, you can imagine my shock when I went looking through my archives!

 > cat $HOME/Misc/Backup/mail.general.backup | \
 >    /usr/local/bin/formail -1000s > $HOME/Misc/Backup/temp.general.backup
 > mv -f $HOME/Misc/Backup/temp.general.backup 
$HOME/Misc/Backup/mail.general.backup
 > rm -f $HOME/Misc/Backup/lock.mail.backup.general

The backup script in the procmailex man page is much nicer because it
uses existing facilities to a larger extent. If you want mbox format,
you need to do the following: 

Well, I used to have formail do all of it while it received a new message
-- but that was taking too long, and I figured no big deal if it went over
the limit during the day and got reduced again at night. I used the same
code -- but now it's doing the same thing.

  * Find out how many messages are in the mbox file
  * Subtract 1000 (or however many you want to keep)
  * formail +number < file > newfile

Why not just formail +1000 < file > newfile -- or would that just trash
the first 1000 messages?

Alternatively, as you infer, you could somehow write to the beginning
of the file each time, but that's verrry wasteful. 

yIn what way?

  * When you save a message to backup, also echo an empty line to a
    "counter" file. That way, finding out how many message you have
    on file is simple. (You could also run it through formail twice, 
    the first time to count how many messages you have :-)

Running through formail twice is fine -- I'd rather not keep extra
counting files around though. 

System load isn't an issue -- I'm running it at the late hours of the
night anyhow.

  * If you can be confident your software will quote any extra From_
    lines, grep -c '^From ' mboxfile will tell you how many messages
    you have. 

Hmmm..can't be 100% sure. So I'd rather not...but the worst isn't so bad.

  The following will assume the grep -c thing will work for you.
  This is, of course, untested and with NO WARRANTY for anything,
including MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, or
READABILITY (that's why they use uppercase for these statements, I'm
sure). In other words, test it.

IOW, it's the standard ;-)


 ------------------------------------------------------------------------- 
 | Brock Rozen | brozen(_at_)webdreams(_dot_)com | 
http://www.webdreams.com/~brozen | 
 ------------------------------------------------------------------------- 



<Prev in Thread] Current Thread [Next in Thread>