Search
j0ke.net Open Build Service
>
Projects
>
server:backup
>
rsnapshot
> rsnapshot-kpartx.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File rsnapshot-kpartx.patch of Package rsnapshot (Revision 7)
Currently displaying revision
7
,
show latest
--- ./rsnapshot.orig 2008-10-30 19:54:10.000000000 +0200 +++ rsnapshot 2008-11-03 15:28:07.000000000 +0200 @@ -163,6 +163,9 @@ my $default_ssh_args = undef; my $default_du_args = '-csh'; +# set default for acl_mount +my $acl_mount = 0; + # set default for use_lazy_deletes my $use_lazy_deletes = 0; # do not delete the oldest archive until after backup @@ -801,7 +804,18 @@ next; } } - + # CHECK FOR kpartx (optional) + if ($var eq 'linux_lvm_cmd_kpartx') { + if ((-f "$value") && (-x "$value") && (1 == is_real_local_abs_path($value))) { + $config_vars{'linux_lvm_cmd_kpartx'} = $value; + $line_syntax_ok = 1; + next; + } else { + config_err($file_line_num, "$line - $value is not executable"); + next; + } + } + # CHECK FOR cmd_preexec (optional) if ($var eq 'cmd_preexec') { my $script; # script file (no args) @@ -965,7 +979,7 @@ $line_syntax_ok = 1; # check for lvm - } elsif ( is_linux_lvm_path($src) ) { + } elsif ( my $return_val = is_linux_lvm_path($src) ) { # if it's an lvm path, make sure we have lvm commands and arguments if (!defined($config_vars{'linux_lvm_cmd_lvcreate'})) { config_err($file_line_num, "$line - Cannot handle $src, linux_lvm_cmd_lvcreate not defined in $config_file"); @@ -983,6 +997,10 @@ config_err($file_line_num, "$line - Cannot handle $src, linux_lvm_cmd_umount not defined in $config_file"); next; } + if ($return_val == 2 and !defined($config_vars{'linux_lvm_cmd_kpartx'})) { + config_err($file_line_num, "$line - Cannot handle $src, linux_lvm_cmd_kpartx not defined in $config_file"); + next; + } if (!defined($config_vars{'linux_lvm_snapshotsize'})) { config_err($file_line_num, "$line - Cannot handle $src, linux_lvm_snapshotsize not defined in $config_file"); next; @@ -1216,6 +1234,23 @@ $line_syntax_ok = 1; next; } + # ACL_MOUNT + if ($var eq 'acl_mount') { + if (!defined($value)) { + config_err($file_line_num, "$line - acl_mount can not be blank"); + next; + } + if (!is_boolean($value)) { + config_err( + $file_line_num, "$line - \"$value\" is not a legal value for acl_mount, must be 0 or 1 only" + ); + next; + } + + $acl_mount = $value; + $line_syntax_ok = 1; + next; + } # LOCKFILE if ($var eq 'lockfile') { if (!defined($value)) { config_err($file_line_num, "$line - lockfile can not be blank"); } @@ -1713,6 +1748,11 @@ if (!is_boolean($parsed_opts{'one_fs'})) { return (undef); } + # acl_mount + } elsif ( $name eq 'acl_mount' ) { + if (!is_boolean($parsed_opts{'acl_mount'})) { + return (undef); + } # rsync_short_args } elsif ( $name eq 'rsync_short_args' ) { # must be in the format '-abcde' @@ -2702,12 +2742,13 @@ # returns 1 if it's a syntactically valid LVM path # returns 0 otherwise sub is_linux_lvm_path { - my $path = shift(@_); - - if (!defined($path)) { return (undef); } - if ($path =~ m|^lvm://.*$|) { return (1); } - - return (0); + my $path = shift(@_); + + if (!defined($path)) { return (undef); } + if ($path =~ m|^lvm://.*$|) { return (1); + } elsif ($path =~ m|^lvm-kpartx://.*$|) { return (2); } + + return (0); } # accepts proposed list for rsync_short_args @@ -3313,8 +3354,10 @@ my $using_relative = 0; my $linux_lvm = 0; + my $linux_lvm_mountopts = undef; my $linux_lvm_oldpwd = undef; my $linux_lvm_snapshotname = undef; + my $linux_lvm_kpartx = undef; if (defined($$bp_ref{'src'})) { $src = remove_trailing_slash( "$$bp_ref{'src'}" ); @@ -3444,7 +3487,15 @@ } elsif ($one_fs) { $rsync_short_args .= 'x'; } - + # ACL_MOUNT + if ( defined($$bp_ref{'opts'}) && defined($$bp_ref{'opts'}->{'acl_mount'}) ) { + if (1 == $$bp_ref{'opts'}->{'acl_mount'}) { + $linux_lvm_mountopts .= ',acl'; + } + } elsif ($acl_mount) { + $linux_lvm_mountopts .= ',acl'; + } + # SEE WHAT KIND OF SOURCE WE'RE DEALING WITH # # local filesystem @@ -3474,7 +3525,7 @@ if ($verbose < 2) { $rsync_short_args .= 'q'; } # LVM path - } elsif ( is_linux_lvm_path($$bp_ref{'src'}) ) { + } elsif ( my $return_value = is_linux_lvm_path($$bp_ref{'src'}) ) { # take LVM snapshot and mount, reformat src into local path unless (defined($config_vars{'linux_lvm_snapshotsize'})) { @@ -3490,13 +3541,23 @@ bail("Missing required argument for LVM source: linux_lvm_mountpath"); } - # parse LVM src ('lvm://vgname/volname/path') - my ($linux_lvmvgname,$linux_lvmvolname, $linux_lvmpath) = ($$bp_ref{'src'} =~ m|^lvm://([^/]+)/([^/]+)/(.*)$|); - # lvmvolname and/or path could be the string "0", so test for 'defined': - unless (defined($linux_lvmvgname) and defined($linux_lvmvolname) and defined($linux_lvmpath)) { - bail("Could not understand LVM source \"$$bp_ref{'src'}\" in backup_lowest_interval()"); - } - + my ($linux_lvmvgname,$linux_lvmvolname, $linux_lvmpartnum, $linux_lvmpath); + if ($return_value == 2) { + # parse LVM src {'lvm-kpartx://vgname/volname/partnum/path'} + ($linux_lvmvgname,$linux_lvmvolname, $linux_lvmpartnum, $linux_lvmpath) = ($$bp_ref{'src'} =~ m|^lvm-kpartx://([^/]+)/([^/]+)/(\d+)/(.*)$|); + # lvmvolname and/or path could be the string "0", so test for 'defined': + unless (defined($linux_lvmvgname) and defined($linux_lvmvolname) and defined($linux_lvmpartnum) and defined($linux_lvmpath)) { + bail("Could not understand LVM source \"$$bp_ref{'src'}\" in backup_lowest_interval()"); + } + } else { + # parse LVM src ('lvm://vgname/volname/path') + ($linux_lvmvgname,$linux_lvmvolname, $linux_lvmpath) = ($$bp_ref{'src'} =~ m|^lvm://([^/]+)/([^/]+)/(.*)$|); + # lvmvolname and/or path could be the string "0", so test for 'defined': + unless (defined($linux_lvmvgname) and defined($linux_lvmvolname) and defined($linux_lvmpath)) { + bail("Could not understand LVM source \"$$bp_ref{'src'}\" in backup_lowest_interval()"); + } + } + # assemble and execute LVM snapshot command @cmd_stack = (); push(@cmd_stack, $config_vars{'linux_lvm_cmd_lvcreate'}); @@ -3520,12 +3581,35 @@ } } + $linux_lvm_snapshotname = join('/', $config_vars{'linux_lvm_vgpath'}, $linux_lvmvgname, $config_vars{'linux_lvm_snapshotname'}); + # kpartx add snapshot + if ($return_value == 2) { + @cmd_stack = (); + #static kpartx args + my $kpartx_add_args = '-ap_'; + push(@cmd_stack, $config_vars{'linux_lvm_cmd_kpartx'}); + push(@cmd_stack, $kpartx_add_args); + push (@cmd_stack, $linux_lvm_snapshotname); + print_cmd(@cmd_stack); + if (0 == $test) { + $result = system(@cmd_stack); + if ($result != 0) { + bail("Kpartx add for LVM snapshot failed: $result"); + } + } + + } + # mount the snapshot @cmd_stack = (); push(@cmd_stack, $config_vars{'linux_lvm_cmd_mount'}); - - $linux_lvm_snapshotname = join('/', $config_vars{'linux_lvm_vgpath'}, $linux_lvmvgname, $config_vars{'linux_lvm_snapshotname'}); + push(@cmd_stack, '-o', $linux_lvm_mountopts) if (defined($linux_lvm_mountopts)); + if ($return_value == 2) { + $linux_lvm_kpartx = join('/', $config_vars{'linux_lvm_vgpath'}, 'mapper', $config_vars{'linux_lvm_snapshotname'}) . '_' . $linux_lvmpartnum; + push(@cmd_stack, $linux_lvm_kpartx); + } else { push(@cmd_stack, $linux_lvm_snapshotname); + } push(@cmd_stack, $config_vars{'linux_lvm_mountpath'}); print_cmd(@cmd_stack); @@ -3732,7 +3816,7 @@ print_cmd(@cmd_stack); if (0 == $test) { - # silence gratuitous lvremove output + # silence gratuitous umount output #$result = system(@cmd_stack); $result = system(join " ", @cmd_stack, ">/dev/null"); @@ -3740,6 +3824,23 @@ bail("Unmount LVM snapshot failed: $result"); } } + # kpartx mapping del for snapshot + if (defined($linux_lvm_kpartx)) { + @cmd_stack = (); + #static kpartx args + my $kpartx_del_args = '-dp_'; + push(@cmd_stack, $config_vars{'linux_lvm_cmd_kpartx'}); + push(@cmd_stack, $kpartx_del_args); + push (@cmd_stack, $linux_lvm_snapshotname); + print_cmd(@cmd_stack); + if (0 == $test) { + $result = system(@cmd_stack); + if ($result != 0) { + bail("Kpartx deletion for LVM snapshot failed: $result"); + } + } + + } @cmd_stack = (); push(@cmd_stack, $config_vars{'linux_lvm_cmd_lvremove'}); @@ -3749,6 +3850,8 @@ print_cmd(@cmd_stack); if (0 == $test) { + # silence gratuitous lvremove output + #$result = system(@cmd_stack); $result = system(join " ", @cmd_stack, ">/dev/null"); if ($result != 0) {