Changeset 7bf0fb24f607559b1f4fdbe921349bbe8c9ebb50
- Timestamp:
- 04/18/07 15:14:56
(6 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1176909296 +0000
- git-parent:
[005a6e999d24b982ddb035d9e43411aba3462b7d]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1176909296 +0000
- Message:
add a -sv flag that displays retention policy violations
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r005a6e9 |
r7bf0fb2 |
|
| 16 | 16 | $PREFIX $CONF $BLOCKSIZE $DEBUG $HOST $BACKUP |
|---|
| 17 | 17 | $RESTORE $RESTORE_HOST $RESTORE_ZFS $TIMESTAMP |
|---|
| 18 | | $LIST $SUMMARY $SUMMARY_EXT $FORCE_FULL |
|---|
| 19 | | $EXPUNGE $NEUTERED $ZFS |
|---|
| | 18 | $LIST $SUMMARY $SUMMARY_EXT $SUMMARY_VIOLATORS |
|---|
| | 19 | $FORCE_FULL $EXPUNGE $NEUTERED $ZFS |
|---|
| 20 | 20 | $VERSION $HELP/; |
|---|
| 21 | 21 | $version_string = '0.1'; |
|---|
| … | … | |
| 37 | 37 | zetaback -v |
|---|
| 38 | 38 | |
|---|
| 39 | | zetaback [-l | -s | -sx] [-c conf] [-d] [-h host] [-z zfs] |
|---|
| | 39 | zetaback [-l | -s | -sx | -sv] [-c conf] [-d] [-h host] [-z zfs] |
|---|
| 40 | 40 | |
|---|
| 41 | 41 | zetaback -b [-f] [-x] [-c conf] [-d] [-n] [-h host] [-z zfs] |
|---|
| … | … | |
| 56 | 56 | "s" => \$SUMMARY, |
|---|
| 57 | 57 | "sx" => \$SUMMARY_EXT, |
|---|
| | 58 | "sv" => \$SUMMARY_VIOLATORS, |
|---|
| 58 | 59 | "r" => \$RESTORE, |
|---|
| 59 | 60 | "t=i" => \$TIMESTAMP, |
|---|
| … | … | |
| 74 | 75 | $actions++ if($SUMMARY); |
|---|
| 75 | 76 | $actions++ if($SUMMARY_EXT); |
|---|
| | 77 | $actions++ if($SUMMARY_VIOLATORS); |
|---|
| 76 | 78 | $actions++ if($VERSION); |
|---|
| 77 | 79 | if($actions != 1) { |
|---|
| … | … | |
| 176 | 178 | they exist. For incremental backups, the detail will include any |
|---|
| 177 | 179 | incremental backups that are more recent than the last full backup. |
|---|
| | 180 | |
|---|
| | 181 | =item -sv |
|---|
| | 182 | |
|---|
| | 183 | Display all ZFS disks in the current store that violate the configured |
|---|
| | 184 | retention policy. |
|---|
| 178 | 185 | |
|---|
| 179 | 186 | =item -b |
|---|
| … | … | |
| 739 | 746 | } |
|---|
| 740 | 747 | |
|---|
| | 748 | sub pretty_print_backup($$$) { |
|---|
| | 749 | my ($info, $host, $point) = @_; |
|---|
| | 750 | my $tf = config_get($host, 'time_format'); |
|---|
| | 751 | print "\t" . strftime($tf, localtime($point)) . " [$point] "; |
|---|
| | 752 | if(exists($info->{full}->{$point})) { |
|---|
| | 753 | my @st = stat($info->{full}->{$point}->{file}); |
|---|
| | 754 | print "FULL " . pretty_size($st[7]); |
|---|
| | 755 | } else { |
|---|
| | 756 | my @st = stat($info->{incremental}->{$point}->{file}); |
|---|
| | 757 | print "INCR from [$info->{incremental}->{$point}->{depends}] " . pretty_size($st[7]); |
|---|
| | 758 | } |
|---|
| | 759 | print "\n"; |
|---|
| | 760 | } |
|---|
| | 761 | |
|---|
| 741 | 762 | sub show_backups($$$) { |
|---|
| 742 | 763 | my ($host, $store, $diskpat) = @_; |
|---|
| … | … | |
| 750 | 771 | !($disk eq $diskpat || # be a specific match or a |
|---|
| 751 | 772 | ($diskpat =~ /^\/(.+)\/$/ && $disk =~ /$1/))); # regex |
|---|
| | 773 | |
|---|
| | 774 | my @backup_points = (keys %{$info->{full}}, keys %{$info->{incremental}}); |
|---|
| | 775 | @backup_points = sort { $a <=> $b } @backup_points; |
|---|
| | 776 | @backup_points = (pop @backup_points) unless ($SUMMARY_EXT || $SUMMARY_VIOLATORS); |
|---|
| | 777 | |
|---|
| | 778 | # Quick short-circuit in the case of retention violation checks |
|---|
| | 779 | if($SUMMARY_VIOLATORS) { |
|---|
| | 780 | if(time() > $info->{last_full} + config_get($host, 'full_interval') || |
|---|
| | 781 | time() > $info->{last_backup} + config_get($host, 'backup_interval')) { |
|---|
| | 782 | print "$host:$disk\n"; |
|---|
| | 783 | pretty_print_backup($info, $host, $backup_points[0]); |
|---|
| | 784 | } |
|---|
| | 785 | next; |
|---|
| | 786 | } |
|---|
| | 787 | |
|---|
| 752 | 788 | # We want to see this one |
|---|
| 753 | 789 | print "$host:$disk\n"; |
|---|
| … | … | |
| 759 | 795 | } |
|---|
| 760 | 796 | } |
|---|
| 761 | | my @backup_points = (keys %{$info->{full}}, keys %{$info->{incremental}}); |
|---|
| 762 | | @backup_points = sort { $a <=> $b } @backup_points; |
|---|
| 763 | | unless ($SUMMARY_EXT) { |
|---|
| 764 | | @backup_points = (pop @backup_points); |
|---|
| 765 | | } |
|---|
| 766 | 797 | foreach (@backup_points) { |
|---|
| 767 | | print "\t" . strftime($tf, localtime($_)) . " [$_] "; |
|---|
| 768 | | if(exists($info->{full}->{$_})) { |
|---|
| 769 | | my @st = stat($info->{full}->{$_}->{file}); |
|---|
| 770 | | print "FULL " . pretty_size($st[7]); |
|---|
| 771 | | } else { |
|---|
| 772 | | my @st = stat($info->{incremental}->{$_}->{file}); |
|---|
| 773 | | print "INCR from [$info->{incremental}->{$_}->{depends}] " . pretty_size($st[7]); |
|---|
| 774 | | } |
|---|
| 775 | | print "\n"; |
|---|
| | 798 | pretty_print_backup($info, $host, $_); |
|---|
| 776 | 799 | } |
|---|
| 777 | 800 | print "\n"; |
|---|
| … | … | |
| 891 | 914 | mkdir $store if(! -d $store); |
|---|
| 892 | 915 | |
|---|
| 893 | | if($LIST || $SUMMARY || $SUMMARY_EXT) { |
|---|
| | 916 | if($LIST || $SUMMARY || $SUMMARY_EXT || $SUMMARY_VIOLATORS) { |
|---|
| 894 | 917 | show_backups($host, $store, $ZFS); |
|---|
| 895 | 918 | } |
|---|