summaryrefslogtreecommitdiffstats
path: root/lib/App/BorgRestore/Borg.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App/BorgRestore/Borg.pm')
-rw-r--r--lib/App/BorgRestore/Borg.pm23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/App/BorgRestore/Borg.pm b/lib/App/BorgRestore/Borg.pm
index c1774d7..660eb8e 100644
--- a/lib/App/BorgRestore/Borg.pm
+++ b/lib/App/BorgRestore/Borg.pm
@@ -3,6 +3,8 @@ use v5.10;
use warnings;
use strict;
+use App::BorgRestore::Helper;
+
use Function::Parameters;
use IPC::Run qw(run start new_chunker);
use Log::Any qw($log);
@@ -31,6 +33,27 @@ method borg_list() {
return \@archives;
}
+method borg_list_time() {
+ my @archives;
+
+ $log->debug("Getting archive list");
+ run [qw(borg list), $self->{borg_repo}], '>', \my $output or die "borg list returned $?";
+
+ for (split/^/, $output) {
+ if (m/^([^\s]+)\s+(.+)$/) {
+ my $time = App::BorgRestore::Helper::parse_borg_time($2);
+ if ($time) {
+ push @archives, {
+ "archive" => $1,
+ "modification_time" => $time,
+ };
+ }
+ }
+ }
+
+ return \@archives;
+}
+
method restore($components_to_strip, $archive_name, $path) {
$log->debugf("Restoring '%s' from archive %s, stripping %d components of the path", $path, $archive_name, $components_to_strip);
system(qw(borg extract -v --strip-components), $components_to_strip, $self->{borg_repo}."::".$archive_name, $path);