From 82e9a44c0a054c2881b8d03443486cec66881997 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 12 Apr 2007 07:10:56 +0000 Subject: [PATCH] ebl add relocation code git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4537 91ce42f0-d328-0410-95d8-f526ca767f89 --- gui/brestore/brestore-fr.glade | 532 +++++++++++++++++++++++++------- gui/brestore/brestore.glade | 534 ++++++++++++++++++++++++++------- gui/brestore/brestore.pl | 99 +++++- gui/bweb/cgi/bconsole.pl | 3 +- gui/bweb/lib/Bweb.pm | 10 +- 5 files changed, 957 insertions(+), 221 deletions(-) diff --git a/gui/brestore/brestore-fr.glade b/gui/brestore/brestore-fr.glade index 5d605e21f3..d93b83cc5b 100644 --- a/gui/brestore/brestore-fr.glade +++ b/gui/brestore/brestore-fr.glade @@ -2674,117 +2674,23 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl - + True 0 0.5 GTK_SHADOW_NONE - - 3 + True 0.5 0.5 1 1 - 5 + 0 0 - 20 - 30 - - - - True - False - 10 - - - - True - True - True - - - 0 - False - True - - - - - - True - Ou restaurer - True - True - True - 0 - /tmp/bacula-restore - True - * - False - - - 0 - True - True - - - - - - - - - - True - <b>Destination</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - label_item - - - - - 0 - False - True - - - - - - 3 - True - True - False - 0 - - - - True - 0.5 - 0.5 - 1 - 1 - 3 - 3 12 - 5 + 0 @@ -2947,7 +2853,7 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl - + True False 3 @@ -2962,7 +2868,7 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl GTK_UPDATE_ALWAYS False False - 10 1 100 1 10 10 + 9 1 100 1 10 10 0 @@ -2972,7 +2878,7 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl - + True Priorité False @@ -3002,7 +2908,7 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl 0 1 fill - fill + @@ -3011,7 +2917,7 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl - + True <b>Options</b> False @@ -3033,6 +2939,426 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl + + 0 + False + True + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + False + 0 + + + + 3 + True + 0.5 + 0.5 + 1 + 1 + 5 + 0 + 20 + 30 + + + + True + False + 10 + + + + True + True + True + + + 0 + False + True + + + + + + True + Ou restaurer + True + True + True + 0 + /tmp/bacula-restore + True + * + False + + + 0 + True + True + + + + + + + 0 + True + True + + + + + + 6 + True + True + True + 0 + + + + 3 + True + False + 0 + + + + 3 + True + True + Utiliser la re-localisation + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + False + False + + + + + + 6 + True + 5 + 2 + False + 3 + 5 + + + + True + Ajouter un suffix : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + False + Utiliser ".old" ici pour restauter tous les fichier en fichier.old + True + True + True + 0 + + True + ● + False + + + 1 + 2 + 2 + 3 + + + + + + + True + Where regexp : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + False + A bacula regexp uses "!" as separator. Like in !/opt!/tmp! + True + True + True + 0 + + True + ● + False + + + 1 + 2 + 4 + 5 + + + + + + + True + False + Supprimer une partie du path source (/tmp/fichier -> /fichier) + True + True + True + 0 + + True + ● + False + + + 1 + 2 + 0 + 1 + + + + + + + True + Supprimer un prefix : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + False + Ajouter un prefix au path destination (/etc -> /tmp/etc) + True + True + True + 0 + + True + ● + False + + + 1 + 2 + 1 + 2 + + + + + + + True + Ajouter un prefix : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + False + True + Utiliser une expression +régulière + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + 1 + 3 + 4 + fill + + + + + + 0 + True + True + + + + + + + + True + Options de re-localisation des fichiers... + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + + + True + <b>Destination</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + 0 True diff --git a/gui/brestore/brestore.glade b/gui/brestore/brestore.glade index b32a8e693e..595c5390ae 100644 --- a/gui/brestore/brestore.glade +++ b/gui/brestore/brestore.glade @@ -1135,7 +1135,7 @@ This year True - <small>Bacula Copyright ©2000-2006FSF Europe</small> + <small>Bacula Copyright ©2000-2007FSF Europe</small> False True @@ -2678,117 +2678,23 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl - + True 0 0.5 GTK_SHADOW_NONE - - 3 + True 0.5 0.5 1 1 - 5 + 0 0 - 20 - 30 - - - - True - False - 10 - - - - True - True - True - - - 0 - False - True - - - - - - True - Where to restore - True - True - True - 0 - /tmp/bacula-restore - True - * - False - - - 0 - True - True - - - - - - - - - - True - <b>Destination</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - label_item - - - - - 0 - False - True - - - - - - 3 - True - True - False - 0 - - - - True - 0.5 - 0.5 - 1 - 1 - 3 - 3 12 - 5 + 0 @@ -2951,7 +2857,7 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl - + True False 3 @@ -2966,7 +2872,7 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl GTK_UPDATE_ALWAYS False False - 10 1 100 1 10 10 + 9 1 100 1 10 10 0 @@ -2976,7 +2882,7 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl - + True Priority False @@ -3006,7 +2912,7 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl 0 1 fill - fill + @@ -3015,9 +2921,427 @@ http://user:pass@director/cgi-bin/bweb/bconsole.pl - + + True + <b>Options</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + False + True + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + True - <b>More Options</b> + False + 0 + + + + 3 + True + 0.5 + 0.5 + 1 + 1 + 5 + 0 + 20 + 30 + + + + True + False + 10 + + + + True + True + True + + + 0 + False + True + + + + + + True + Where to restore + True + True + True + 0 + /tmp/bacula-restore + True + * + False + + + 0 + True + True + + + + + + + 0 + True + True + + + + + + 6 + True + True + False + 0 + + + + 3 + True + False + 0 + + + + 3 + True + True + Use file relocation + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + False + False + + + + + + 6 + True + 5 + 2 + False + 3 + 5 + + + + True + Add suffix: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + False + Put ".old" here to get all restored files to files.old + True + True + True + 0 + + True + ● + False + + + 1 + 2 + 2 + 3 + + + + + + + True + Where regexp: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + False + A bacula regexp uses "!" as separator. Like in !/opt!/tmp! + True + True + True + 0 + + True + ● + False + + + 1 + 2 + 4 + 5 + + + + + + + True + False + Removed from path (be sure to keep a / at the begining of your path) + True + True + True + 0 + + True + ● + False + + + 1 + 2 + 0 + 1 + + + + + + + True + Strip prefix: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + False + True + True + True + 0 + + True + ● + False + + + 1 + 2 + 1 + 2 + + + + + + + True + Add prefix: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + False + True + Use regexp + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + 1 + 3 + 4 + fill + + + + + + 0 + True + True + + + + + + + + True + More relocation options... + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + + + True + <b>Destination</b> False True GTK_JUSTIFY_LEFT diff --git a/gui/brestore/brestore.pl b/gui/brestore/brestore.pl index e019f7af66..33f17328b1 100755 --- a/gui/brestore/brestore.pl +++ b/gui/brestore/brestore.pl @@ -71,7 +71,7 @@ use Gtk2::SimpleList; # easy wrapper for list views use Gtk2::Gdk::Keysyms; # keyboard code constants use Data::Dumper qw/Dumper/; my $debug=0; # can be on brestore.conf -our ($VERSION) = ('$Revision$' =~ /(\d+\.\d+)/); +our ($VERSION) = ('$Revision$' =~ /(\d+)/); package Pref; use DBI; @@ -656,12 +656,89 @@ To follow it, you must use bconsole (or install/configure bweb)"); } } +sub on_use_regexp_toggled +{ + my ($self,$widget) = @_; + my $act = $widget->get_active(); + + foreach my $w ('entry_launch_where') { + $self->{glade}->get_widget($w)->set_sensitive(!$act); + } + + foreach my $w ('entry_add_prefix', 'entry_strip_prefix', + 'entry_add_suffix','entry_rwhere','chk_use_regexp') + { + $self->{glade}->get_widget($w)->set_sensitive($act); + } + + if ($act) { # if we activate file relocation, we reset use_regexp + $self->{glade}->get_widget('entry_rwhere')->set_sensitive(0); + $self->{glade}->get_widget('chk_use_regexp')->set_active(0); + } +} + + +sub on_use_rwhere_toggled +{ + my ($self,$widget) = @_; + my $act = $widget->get_active(); + + foreach my $w ('entry_rwhere') { + $self->{glade}->get_widget($w)->set_sensitive($act); + } + + foreach my $w ('entry_add_prefix', 'entry_strip_prefix', + 'entry_add_suffix') + { + $self->{glade}->get_widget($w)->set_sensitive(!$act); + } +} + sub on_cancel_resto_clicked { my ($self) = @_ ; $self->{glade}->get_widget('dlg_launch')->destroy(); } +sub get_where +{ + my ($self) = @_ ; + + if ($self->{glade}->get_widget('chk_file_relocation')->get_active()) { + # using regexp + if ($self->{glade}->get_widget('chk_use_regexp')->get_active()) { + + return ('rwhere', + $self->{glade}->get_widget('entry_rwhere')->get_active()); + } + + # using regexp utils + my @ret; + my ($strip_prefix, $add_prefix, $add_suffix) = + ($self->{glade}->get_widget('entry_strip_prefix')->get_text(), + $self->{glade}->get_widget('entry_add_prefix')->get_text(), + $self->{glade}->get_widget('entry_add_suffix')->get_text()); + + if ($strip_prefix) { + push @ret,"!$strip_prefix!!i"; + } + + if ($add_prefix) { + push @ret,"!^!$add_prefix!"; + } + + if ($add_suffix) { + push @ret,"!([^/])$!\$1$add_prefix!"; + } + + return ('rwhere', join(',', @ret)); + + } else { # using where + return ('where', + $self->{glade}->get_widget('entry_launch_where')->get_text()); + } +} + sub on_submit_resto_clicked { my ($self) = @_ ; @@ -680,7 +757,8 @@ sub on_submit_resto_clicked my $storage = $glade->get_widget('combo_launch_storage') ->get_active_text(); - my $where = $glade->get_widget('entry_launch_where')->get_text(); + my ($where_cmd, $where) = $self->get_where(); + print "$where_cmd => $where\n"; my $job = $glade->get_widget('combo_launch_job') ->get_active_text(); @@ -707,7 +785,7 @@ sub on_submit_resto_clicked client => $client, storage => $storage, fileset => $fileset, - where => $where, + $where_cmd => $where, replace => $replace, priority=> $prio, bootstrap => $r); @@ -2065,7 +2143,7 @@ WHERE Job.JobId = JobMedia.JobId # path, volsessiontime DESC (get the most recent file...) # The array rows look like this : # complete_path,is_dir,fileindex, - # ref->(jobid,VolsessionId,VolsessionTime,File,FirstIndex, + # ref->(jobid,VolsessionId,VolsessionTime,File,FirstIndex, # LastIndex,StartBlock-EndBlock,VolIndex,Volumename,MediaType) @temp_list = sort {$a->[0] cmp $b->[0] || $b->[3]->[2] <=> $a->[3]->[2] @@ -2173,11 +2251,11 @@ WHERE Job.JobId = JobMedia.JobId or $prev_volfile ne $volfile) { # We have to create a new section in the bsr... - # We print the previous one ... + #Â We print the previous one ... # (before that, save the current range ...) if ($first_of_current_range != $prev_fileindex) { - # we are in a range + #Â we are in a range push @fileindex_ranges, ("$first_of_current_range-$prev_fileindex"); } @@ -2669,7 +2747,7 @@ sub get_all_file_versions if ($ref->[8]) { # The file has a md5. We compare his md5 to other known md5... - # We take size into account. It may happen that 2 files + # We take size into account. It may happen that 2 files # have the same md5sum and are different. size is a supplementary # criterion @@ -2680,7 +2758,7 @@ sub get_all_file_versions # we never met this one before... $allready_seen_by_md5{$ref->[8] .'-'. $ref->[6]}=1; } - # Even if it has a md5, we should also work with mtimes + # Even if it has a md5, we should also work with mtimes # We allready have a (better) version next if ( (not $see_all) and $allready_seen_by_mtime{$ref->[5] .'-'. $ref->[6]}); @@ -3126,9 +3204,10 @@ sub run client => $arg{client}, storage => $arg{storage} || '', fileset => $arg{fileset} || '', - where => $arg{where}, - replace => $arg{replace}, + where => $arg{where} || '', + rwhere => $arg{rwhere} || '', priority=> $arg{prio} || '', + replace => $arg{replace}, action => 'run', timeout => 10, bootstrap => [$arg{bootstrap}], diff --git a/gui/bweb/cgi/bconsole.pl b/gui/bweb/cgi/bconsole.pl index 2bc6748130..8444151c17 100755 --- a/gui/bweb/cgi/bconsole.pl +++ b/gui/bweb/cgi/bconsole.pl @@ -85,7 +85,7 @@ for my $a (@action) } elsif ($a eq 'run' and $have_run==0) { $have_run=1; - my $arg = $bweb->get_form(qw/job client storage fileset + my $arg = $bweb->get_form(qw/job client storage fileset rwhere where replace priority/); my $bootstrap = CGI::param('bootstrap'); @@ -107,6 +107,7 @@ for my $a (@action) storage => $arg->{storage}, fileset => $arg->{fileset}, where => $arg->{where}, + rwhere => $arg->{rwhere}, replace => $arg->{replace}, priority => $arg->{priority}, bootstrap => $filename); diff --git a/gui/bweb/lib/Bweb.pm b/gui/bweb/lib/Bweb.pm index 007ff64299..722d0c417b 100644 --- a/gui/bweb/lib/Bweb.pm +++ b/gui/bweb/lib/Bweb.pm @@ -1076,7 +1076,7 @@ sub dbh_disconnect my ($self) = @_; if ($self->{dbh}) { $self->{dbh}->disconnect(); - undef self->{dbh}; + undef $self->{dbh}; } } @@ -1401,6 +1401,7 @@ sub get_form device => 1, where => 1, ); + my %opt_r = (rwhere => 1); my %opt_d = ( # option with date voluseduration=> 1, @@ -1443,6 +1444,11 @@ sub get_form if ($value =~ /^([\w\d\.\/\s:\@\-]+)$/) { $ret{$i} = $1; } + } elsif (exists $opt_r{$i}) { + my $value = CGI::param($i) || ''; + if ($value =~ /^([^'"']+)$/) { + $ret{$i} = $1; + } } elsif (exists $opt_d{$i}) { my $value = CGI::param($i) || ''; if ($value =~ /^\s*(\d+\s+\w+)$/) { @@ -2457,7 +2463,7 @@ INSERT LocationLog (Date, Comment, MediaId, LocationId, NewVolStatus) $self->display({ email => $self->{info}->{email_media}, url => $url, newlocation => $newloc, - # [ { volumename => 'vol1' }, { volumename => 'vol2' },..] + # [ { volumename => 'vol1' }, { volumename => 'vol2' },..] medias => [ values %$medias ], }, "change_location.tpl"); -- 2.39.5