# HG changeset patch # User Heiko Schlittermann (JUMPER) # Date 1387277005 -3600 # Node ID 4e072a6ae1f3030c9093d081dd8358923525e808 # Parent 9e30f40ffb3431f899b17730d3c32943b73a3d16 restore command works too diff -r 9e30f40ffb34 -r 4e072a6ae1f3 bin/amdumpext --- a/bin/amdumpext Mon Dec 16 21:19:41 2013 +0100 +++ b/bin/amdumpext Tue Dec 17 11:43:25 2013 +0100 @@ -23,8 +23,6 @@ use File::Basename; use POSIX; -#use Readonly; - our $VERSION = '0.01'; my $ME = basename $0; @@ -54,6 +52,7 @@ CALCSIZE => NO, # estimate --calcsize # RECORD => YES, # --record + COLLECTION => NO, ); sub exec_support; @@ -61,6 +60,7 @@ sub exec_estimate; sub exec_backup; sub exec_validate; +sub exec_restore; # some helper functions @@ -80,8 +80,8 @@ my $opt_dumpdates; MAIN: { - my @argv = @ARGV; my $command = shift // pod2usage; + #warn "<<< $command | @ARGV >>>\n"; GetOptions( 'config=s' => \$opt_config, 'device=s' => \$opt_device, # --device $device @@ -95,21 +95,20 @@ ) or pod2usage; given ($command) { - when ('support') { exec_support } + when ('support') { exec_support } + when ('validate') { exec_validate } + when ('restore') { exec_restore @ARGV } when ('selfcheck') { pod2usage if undef ~~ $opt_device; - exec_selfcheck + exec_selfcheck; } when ('estimate') { pod2usage if undef ~~ [$opt_device, $opt_level[0]]; - exec_estimate + exec_estimate; } when ('backup') { pod2usage if undef ~~ [$opt_device, $opt_level[0]]; - exec_backup - } - when ('validate') { - exec_validate + exec_backup; } default { pod2usage } @@ -425,7 +424,7 @@ my $pid = fork // die "Can't fork: $!\n"; open(STDOUT, '>', '/dev/null') - or die "Can't redirect STDOUT to /dev/null: $!\n"; + or die "Can't redirect STDOUT to /dev/null: $!\n"; # the first part goes into restore # but restore stops reading after the directory @@ -442,6 +441,19 @@ die "Can't exec `cat': $!\n"; } +sub exec_restore { + if (not @_ or $_[0] eq '.') { + # complete file system restore + exec 'restore', '-yrf', '-'; + } + + # just some files - in this mode + # no true incremental restore can be done + # (it will just add new files or do updates, but it + # won't remove any files!) + exec 'restore', '-yxf', '-', @_; +} + sub device { my $_ = shift; return $_ if /^\//; @@ -463,11 +475,12 @@ =head1 SYNOPSIS - amdumpext support + amdumpext support [options] amdumpext selfcheck [options] [--level ] --device amdumpext backup [options] [--level ] --device amdumpext estimate [options] [--level ]... --device - amdumpext validate + amdumpext validate [options] + amdumpext restore [options] =head1 DESCRIPTION @@ -475,12 +488,11 @@ native ext2/3/4 dump/restore programs found on most Linux systems. See L and L for more information on these tools. -=head1 COMMANDS +=head1 OPTIONS -The B supports the commands from the API description found on -L. - -=head1 COMMON OPTIONS +The commands may need some options. These options are noted per command. +Unsupported options are silently ignored. Unknown options are not +allowed. =over @@ -516,8 +528,27 @@ =back +=head1 PROPERTIES + +The properties may be set on the server side to tune the behaviour +of the application. Currently property setting on the client side is +not supported. + +=over 4 + +=item B<--dumpdates> I + +The location of the dumpdates file. Placeholder "${c}" is allowed and +replaced by the name of the current config. + +=back + + =head1 COMMANDS +The B supports the commands from the API description found on +L. + =head2 support This command returns the list of supported features. @@ -542,20 +573,9 @@ Actually it does not try to completly validate the stream, as B does not have such an option. -=head1 PROPERTIES - -The properties may be set on the server side to tune the behaviour -of the application. Currently property setting on the client side is -not supported. +=head2 restore -=over 4 - -=item B<--dumpdates> I - -The location of the dumpdates file. Placeholder "${c}" is allowed and -replaced by the name of the current config. - -=back +Restore from a single dump. =head1 TESTING