/[sysadmin-cookbook]/recepies/zfs/zfs-expire-snapshot.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

Diff of /recepies/zfs/zfs-expire-snapshot.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 118 by dpavlin, Thu Jul 9 10:14:40 2009 UTC revision 263 by dpavlin, Thu May 26 18:22:29 2011 UTC
# Line 6  use strict; Line 6  use strict;
6  use DateTime;  use DateTime;
7  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
8    
9  my $debug = 0;  my $debug = $ENV{DEBUG} || 0;
10    
11  my $config = {  my $config = {
12          'default' => {          'default' => {
13                  21 => 5,                  21 => 5,
14                  30 => 10,                  30 => 10,
15                  60 => 30,                  90 => 30,
16          },          },
17          '212052' => {   # koha-dev          '212052' => {   # koha-dev
18                  7 => 10,                  7 => 10,
# Line 20  my $config = { Line 20  my $config = {
20          },          },
21          '212056' => {   # webpac2          '212056' => {   # webpac2
22                  7 => 5,                  7 => 5,
23                    14 => 30,
24          }          }
25  };  };
26    
# Line 27  my $now = DateTime->now(); Line 28  my $now = DateTime->now();
28    
29  my $last_backup;  my $last_backup;
30    
31  open(my $fs, '-|', 'zfs list -H');  open(my $fs, '-|', 'zfs list -t snapshot -H');
32  while(<$fs>) {  while(<$fs>) {
33          chomp;          chomp;
34          my ( $name, $used, $avail, $refer, $mountpoint ) = split(/\t/,$_,6);          my ( $name, $used, $avail, $refer, $mountpoint ) = split(/\t/,$_,6);
# Line 57  while(<$fs>) { Line 58  while(<$fs>) {
58    
59          my $keep_every_days;          my $keep_every_days;
60          my $older_than_days;          my $older_than_days;
61          foreach ( sort keys %$c ) {          foreach ( sort { $b <=> $a } keys %$c ) {
62                  $older_than_days = $_;                  $older_than_days = $_;
63                  $keep_every_days = $c->{$_};                  $keep_every_days = $c->{$_};
64                  warn "## $host $age > $older_than_days" if $debug;                  warn "## $host $age > $older_than_days" if $debug;

Legend:
Removed from v.118  
changed lines
  Added in v.263

  ViewVC Help
Powered by ViewVC 1.1.26