[H-GEN] chestnut

Sarah Hollings sarah at humanfactors.uq.edu.au
Wed Mar 26 22:36:04 EST 2003


[ Humbug *General* list - semi-serious discussions about Humbug and     ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]

Christopher Biggs wrote:
> Greg Black <gjb at gbch.net> moved upon the face of the 'Net and spake thusly:
> 
> 
>>The correct answer is, of course:
>>
>>    rm `ls -t | tail -1`
>>
>>Note that those are backquotes, not single quotes.

Elegant - that'll do nicely thanks.

>         "why? what do you actually need to achieve?"
> 
> Narrowing the problem domain will help to avoid needlessly baroque

A crude cron job has been quite successfully backing up a Maildir store 
daily to a spare IDE disk mounted on /var/backups/disk2:

45 6 * * * tar cjf /var/backups/disk2/$(date +%d-%m-%Y)-mail.tar.bz2 
/home/imap

This redundant backup is handy as if someone deletes something from 
their IMAP folders by mistake often I can get it back without having to 
go through tapes.

Its very handy, but pretty yukky as at present when it fails (not enough 
room on the disk) I get an email and I remove "a few".  ;-)

I'm thinking of something like
TRY=3
dobackup () {
    tar cjf /var/backups/disk2/$(date +%d-%m-%Y)-mail.tar.bz2 /home/imap
}
while ((( TRY-- )) && ! dobackup()); do
	rm `ls -t | tail -1`
done

Rgds,
-- 
Sarah Hollings                     IT Manager
sarah at humanfactors.uq.edu.au       The ARC Key Centre
Ph +61 7 33656080                  for Human Factors and
Mb +61 416 045401                  Applied Cognitive Psychology


--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.  See http://www.humbug.org.au/



More information about the General mailing list