At 2:25 -0600 22/6/06, Google Kreme wrote:
On 21 Jun 2006, at 21:18 , Peter N Lewis wrote:
Sure, you end up with a folder with 40,000 files taking up 2.5Gig, but it would have saved you this time...

If you are smart, clever, or just know someone smart of clever, you set a cron job to clean out the old files from your backup directory periodically (I do it once a month for files more than 60 days old, so I have 60-90 days worth of mostly worthless backup. But only MOSTLY worthless.)

10 5 1 * * find $HOME/Documents/.backups/ -atime +60 -print0 | xargs -0 rm

Hey, now there is an idea. And how about if it always left at least one copy of the file, even if it was older than 60 days (well, one copy per unique name anyway...).

#!/usr/bin/perl

use strict;
use warnings;

my $base = $ENV{HOME}.'/Documents/BBEdit Backups';
chdir( $base ) or die "Cant change to BBEdit Backup directory";

our %mtimes;
our %basetimes;

while ( <*> ) {
        $mtimes{$_} = -M $_;
        (my $base = $_) =~ s! \(\d\d?-\d\d?-\d\d\)(?:-\d+)?(\..*|)$!$1!;
        $basetimes{$base} = $mtimes{$_}
          unless defined $basetimes{$base}
              && $basetimes{$base} < $mtimes{$_};
}

foreach ( sort keys %mtimes ) {
        (my $base = $_) =~ s! \(\d\d?-\d\d?-\d\d\)(?:-\d+)?(\..*|)$!$1!;
        my $delete = $mtimes{$_} > 60
                  && $mtimes{$_} > $basetimes{$base} + 0.00001;
#       print '',($delete ? 'D' : 'K' ),"$mtimes{$_}\t$basetimes{$base}\t$_\n";
        unlink( $_ ) if $delete;
}

Of course, it probably is worth 2.5Gig to have all those backups... Backups are *good*.

Enjoy,
   Peter.

--
Check out Interarchy 8.1, just released, now with Amazon S3 support.
<http://www.stairways.com/>  <http://download.stairways.com/>

--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to