From 3fa026c805bc5ef9ce1ef5db1c69e8fcc68bba8f Mon Sep 17 00:00:00 2001 From: hjp Date: Fri, 21 Mar 2008 11:12:42 +0000 Subject: [PATCH] Added option filesets to backup only some filesets (instead of all of them). --- backup | 7 +++++++ lib/Simba/CA.pm | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/backup b/backup index 5dba178..5b6eeee 100755 --- a/backup +++ b/backup @@ -3,6 +3,12 @@ use warnings; use strict; use Simba::CA; use POSIX qw(strftime); +use Getopt::Long; + +my @filesets; + +GetOptions('filesets=i' => \@filesets); +@filesets = split(/,/,join(',',@filesets)); $ENV{PATH} = "/usr/bin"; @@ -13,6 +19,7 @@ $log->autoflush(1); my $ca = Simba::CA->new({ dbi_file => $ENV{SIMBA_DB_CONN} || "$ENV{HOME}/.dbi/simba", fh_log => $log, + (@filesets ? ( filesets => \@filesets ) : ()), }); $ca->run(); diff --git a/lib/Simba/CA.pm b/lib/Simba/CA.pm index 123e218..2c5c8a9 100644 --- a/lib/Simba/CA.pm +++ b/lib/Simba/CA.pm @@ -49,6 +49,15 @@ sub new { ); } $self->{targets} = $self->{dbh}->selectall_arrayref("select * from filesets", { Slice => {} }); + if ($opt->{filesets}) { + $self->{targets} = + [ + grep { + my $id = $_->{id}; + grep { $id == $_ } @{ $opt->{filesets} } + } @{ $self->{targets} } + ]; + } if ($ENV{HOME} =~ m{([/\w]*)}) { if (-f "$1/.ssh/id_rsa") { if (my $st = stat("$1/.ssh/id_rsa")) {