/[sysadmin-cookbook]/recepies/btrfs/btrfs-snap-expire.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /recepies/btrfs/btrfs-snap-expire.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 199 - (hide annotations)
Sun Apr 11 20:36:10 2010 UTC (14 years ago) by dpavlin
File MIME type: text/plain
File size: 511 byte(s)
expire snapshots older than 3 days

1 dpavlin 199 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6     use DateTime;
7    
8     my $to = DateTime->now->subtract( days => 3 )->truncate( to => 'day' );
9    
10     foreach my $snap ( glob '/mnt/*/.snap/*' ) {
11     if ( $snap =~ m{^(.+)/((\d\d\d\d)-(\d\d)-(\d\d)T(\d\d))$} ) {
12     my $path = $1;
13     my $name = $2;
14     next if $6 == 0; # keep daily snapshot
15     my $dt = DateTime->new( year => $3, month => $4, day => $5, hour => $6 );
16     next if $dt > $to;
17     warn "remove $snap\n";
18     system "btrfsctl -D $name $path";
19     } else {
20     warn "SKIP $snap\n";
21     }
22     }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26