From 3e409037202ac31ed664e5f53c7bd9e9f0c72dea Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Sun, 4 Aug 2019 22:48:50 +0200 Subject: [PATCH] btrbk: add btrbk archive --raw option --- btrbk | 20 ++++++++++++-------- doc/btrbk.1.asciidoc | 5 ++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/btrbk b/btrbk index 640d4ec..da2fad5 100755 --- a/btrbk +++ b/btrbk @@ -4894,8 +4894,11 @@ MAIN: my @config_override_cmdline; my @exclude_cmdline; - my ($config_cmdline, $preserve_snapshots, $preserve_backups, $wipe_snapshots, $skip_snapshots, $skip_backups, $print_schedule, $lockfile_cmdline); - my $resume_only_DEPRECATED; # as of btrbk-v0.26.0 + my ($config_cmdline, $lockfile_cmdline, $print_schedule, + $preserve_snapshots, $preserve_backups, $wipe_snapshots, $skip_snapshots, $skip_backups, + $archive_raw, + $resume_only_DEPRECATED, # as of btrbk-v0.26.0 + ); unless(GetOptions( 'help|h' => sub { VERSION_MESSAGE(); HELP_MESSAGE(0); exit 0; }, 'version' => sub { VERSION_MESSAGE(); exit 0; }, @@ -4917,6 +4920,7 @@ MAIN: 'print-schedule|S' => \$print_schedule, 'lockfile=s' => \$lockfile_cmdline, 'override=s' => \@config_override_cmdline, # e.g. --override=incremental=no + 'raw' => \$archive_raw, )) { VERSION_MESSAGE(); @@ -5357,8 +5361,8 @@ MAIN: exit 1; } my $archive_root = vinfo($archive_url, $config); - unless(vinfo_init_root($archive_root)) { - ERROR "Failed to fetch subvolume detail for '$archive_root->{PRINT}'" . ($err ? ": $err" : ""); + unless($archive_raw ? vinfo_init_raw_root($archive_root) : vinfo_init_root($archive_root)) { + ERROR "Failed to fetch " . ($archive_raw ? "raw target metadata" : "subvolume detail") . " for '$archive_root->{PRINT}'" . ($err ? ": $err" : ""); exit 1; } @@ -5384,7 +5388,7 @@ MAIN: }; my $config_droot = { CONTEXT => "archive_target", PARENT => $config_sroot, - target_type => "send-receive", # macro_send_receive checks this + target_type => ($archive_raw ? "raw" : "send-receive"), # macro_send_receive checks this url => $droot_url, # ABORTED() needs this }; $config_sroot->{SUBSECTION} = [ $config_droot ]; @@ -5400,8 +5404,8 @@ MAIN: my $droot = vinfo($droot_url, $config_droot); vinfo_assign_config($droot); - unless(vinfo_init_root($droot)) { - DEBUG("Failed to fetch subvolume detail" . ($err ? ": $err" : "")); + unless($archive_raw ? vinfo_init_raw_root($droot) : vinfo_init_root($droot)) { + DEBUG "Failed to fetch " . ($archive_raw ? "raw target metadata" : "subvolume detail") . " for '$droot->{PRINT}'" . ($err ? ": $err" : ""); unless(system_mkdir($droot)) { ABORTED($droot, "Failed to create directory: $droot->{PRINT}/"); WARN "Skipping archive target \"$droot->{PRINT}\": " . ABORTED_TEXT($droot); @@ -5416,7 +5420,7 @@ MAIN: } else { # after directory is created, try to init again - unless(vinfo_init_root($droot)) { + unless($archive_raw ? vinfo_init_raw_root($droot) : vinfo_init_root($droot)) { ABORTED($droot, "Failed to fetch subvolume detail" . ($err ? ": $err" : "")); WARN "Skipping archive target \"$droot->{PRINT}\": " . ABORTED_TEXT($droot); next; diff --git a/doc/btrbk.1.asciidoc b/doc/btrbk.1.asciidoc index aa66278..ec818f5 100644 --- a/doc/btrbk.1.asciidoc +++ b/doc/btrbk.1.asciidoc @@ -237,7 +237,7 @@ as it is still required in order to determine the latest snapshot/backup pair (which is always preserved, regardless of the retention policy). -*archive* :: +*archive* [--raw]:: Recursively copy all subvolumes created by btrbk from to directory, optionally rescheduled using 'archive_preserve_*' configuration options. Also creates directory @@ -250,6 +250,9 @@ need to create them by hand (e.g. by running "btrfs subvolume create /dir"). Check the output of --dry-run if unsure. + Note that this feature needs a *linux kernel >=4.4* to work correctly! ++ +If '--raw' option is set, creates raw targets (experimental, see +btrbk.conf(5), TARGET TYPES). *clean* [filter...]:: Delete incomplete (garbled) backups. Incomplete backups can be