aboutsummaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorAntoine Beaupre <anarcat@koumbit.org>2009-06-18 12:11:41 -0400
committerAntoine Beaupre <anarcat@koumbit.org>2009-06-18 12:11:41 -0400
commit4b24e2921731446d0f311176264efe41fa05f2b8 (patch)
tree28b120444fbb3a661e5cbef8e8d95d528fc4dfe4 /files
parent1ac4ac4eddd76e3fb55ab6c0b932ce9a540bf5c6 (diff)
downloadpuppet-backupninja-4b24e2921731446d0f311176264efe41fa05f2b8.tar.gz
puppet-backupninja-4b24e2921731446d0f311176264efe41fa05f2b8.tar.bz2
add -o flag to treat only one backup, add rsync.log detection
Diffstat (limited to 'files')
-rwxr-xr-xfiles/checkbackups.pl37
1 files changed, 24 insertions, 13 deletions
diff --git a/files/checkbackups.pl b/files/checkbackups.pl
index 2084e86..c621109 100755
--- a/files/checkbackups.pl
+++ b/files/checkbackups.pl
@@ -42,10 +42,11 @@ our $opt_d = "/backup";
our $opt_c = 48 * 60 * 60;
our $opt_w = 24 * 60 * 60;
our $opt_v = 0;
+our $opt_o;
-if (!getopts('d:c:w:v')) {
+if (!getopts('d:c:w:vo')) {
print <<EOF
-Usage: $0 [ -d <backupdir> ] [ -c <threshold> ] [ -w <threshold> ] -v
+Usage: $0 [ -d <backupdir> ] [ -c <threshold> ] [ -w <threshold> ] [ -o ] [ -v ]
EOF
;
exit();
@@ -55,25 +56,35 @@ my $backupdir= $opt_d;
my $crit = $opt_c;
my $warn = $opt_w;
-# XXX: this should be a complete backup registry instead
-my @hosts=qx{ls $backupdir};
+my @hosts;
+if (defined($opt_o)) {
+ @hosts=qx{hostname -f};
+} else {
+ # XXX: this should be a complete backup registry instead
+ @hosts=qx{ls $backupdir};
+}
chdir($backupdir);
my ($state, $message, @vservers, $host);
foreach $host (@hosts) {
chomp($host);
+ if ($opt_o) {
+ $dir = $backupdir;
+ } else {
+ $dir = $host;
+ }
my $flag="";
my $type="unknown";
my $extra_msg="";
@vservers = ();
$state = $STATE_UNKNOWN;
$message = "???";
- if (-d $host) {
+ if (-d $dir) {
# guess the backup type and find a proper stamp file to compare
# XXX: the backup type should be part of the machine registry
my $last_bak;
- if (-d "$host/rdiff-backup") {
- $flag="$host/rdiff-backup/rdiff-backup-data/backup.log";
+ if (-d "$dir/rdiff-backup") {
+ $flag="$dir/rdiff-backup/rdiff-backup-data/backup.log";
$type="rdiff";
if (open(FLAG, $flag)) {
while (<FLAG>) {
@@ -92,21 +103,21 @@ foreach $host (@hosts) {
}
close(FLAG);
foreach my $vserver_dir (@vserver_dirs) {
- $dir = "$host/rdiff-backup$vserver_dir";
+ $dir = "$dir/rdiff-backup$vserver_dir";
if (opendir(DIR, $dir)) {
@vservers = grep { /^[^\.]/ && -d "$dir/$_" } readdir(DIR);
closedir DIR;
}
}
- } elsif (-d "$host/dump") {
+ } elsif (-d "$dir/dump") {
# XXX: this doesn't check backup consistency
- $flag="$host/dump/" . `ls -tr $host/dump | tail -1`;
+ $flag="$dir/dump/" . `ls -tr $dir/dump | tail -1`;
chomp($flag);
$type="dump";
- } elsif (-d "$host/dup") {
+ } elsif (-r "$dir/rsync.log") {
# XXX: this doesn't check backup consistency
- $flag="$host/dup";
- $type="duplicity";
+ $flag="$dir/rsync.log";
+ $type="rsync";
} else {
$message = "unknown system";
next;