From f529b18a48b33911ac2e09ccf7d340aa0b8e9d55 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 12 Aug 2018 20:21:15 +0200 Subject: Add --detail option for archive list when using --list Signed-off-by: Florian Pritz --- Changes | 1 + script/borg-restore.pl | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Changes b/Changes index 936d444..00b2819 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for Perl extension App-BorgRestore {{$NEXT}} + - Add --detail option - Log cache update status message per archive to INFO - Add --quiet option - Remove sqlite cache size warning diff --git a/script/borg-restore.pl b/script/borg-restore.pl index 24dd735..91aae91 100755 --- a/script/borg-restore.pl +++ b/script/borg-restore.pl @@ -14,6 +14,8 @@ borg-restore.pl [options] --help, -h short help message --debug show debug messages --quiet show only warnings and errors + --detail Output additional detail for some operations + (currently only --list) --update-cache, -u update cache files --list [pattern] List paths contained in the backups, optionally matching an SQLite LIKE pattern @@ -76,6 +78,11 @@ Enable debug messages. Reduce output by showing only show warnings and above (errors). +=item B<--detail> + +Output additional detail information with some operations. Refer to the +specific options for more information. Currently only works with B<--list> + =item B<--update-cache>, B<-u> Update the lookup database. You should run this after creating or removing a backup. @@ -86,6 +93,10 @@ List paths contained in the backups, optionally matching an SQLite LIKE pattern. If no % occurs in the pattern, the patterns is automatically wrapped between two % so it may match anywhere in the path. +If B<--detail> is used, also outputs which archives contain a version of the +file. If the same version is part of multiple archives, only one archive is +shown. + =item B<--destination=>I, B<-d >I Restore the backup to 'path' instead of its original location. The destination @@ -162,6 +173,15 @@ use Pod::Usage; my $app; +fun print_archive_list ($archives, $show_counter=1) { + my $counter = 0; + for my $archive (@$archives) { + $counter++; + printf "\e[0;33m%3d: ", $counter if $show_counter; + printf "\e[1;33m%s\e[0m %s\n", App::BorgRestore::Helper::format_timestamp($archive->{modification_time}), $archive->{archive}; + } +} + fun user_select_archive ($archives) { my $selected_archive; @@ -169,10 +189,7 @@ fun user_select_archive ($archives) { return; } - my $counter = 0; - for my $archive (@$archives) { - printf "\e[0;33m%3d: \e[1;33m%s\e[0m %s\n", $counter++, App::BorgRestore::Helper::format_timestamp($archive->{modification_time}), $archive->{archive}; - } + print_archive_list($archives); printf "\e[0;34m%s: \e[0m", "Enter ID to restore (Enter to skip)"; my $selection = ; @@ -224,7 +241,7 @@ sub main { $ENV{PATH} = App::BorgRestore::Helper::untaint($ENV{PATH}, qr(.*)); Getopt::Long::Configure ("bundling"); - GetOptions(\%opts, "help|h", "debug", "update-cache|u", "destination|d=s", "time|t=s", "adhoc", "version", "list", "quiet") or pod2usage(2); + GetOptions(\%opts, "help|h", "debug", "update-cache|u", "destination|d=s", "time|t=s", "adhoc", "version", "list", "quiet", "detail") or pod2usage(2); pod2usage(0) if $opts{help}; if ($opts{version}) { @@ -263,6 +280,7 @@ sub main { my $paths = $app->search_path($pattern); for my $path (@$paths) { printf "%s\n", $path; + print_archive_list($app->find_archives($path), 0) if $opts{detail}; } } return 0; -- cgit v1.2.3-24-g4f1b