summaryrefslogtreecommitdiffstats
path: root/lib/App
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App')
-rw-r--r--lib/App/BorgRestore/Borg.pm39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/App/BorgRestore/Borg.pm b/lib/App/BorgRestore/Borg.pm
new file mode 100644
index 0000000..426f809
--- /dev/null
+++ b/lib/App/BorgRestore/Borg.pm
@@ -0,0 +1,39 @@
+package App::BorgRestore::Borg;
+use v5.10;
+use warnings;
+use strict;
+
+use IPC::Run qw(run start);
+
+sub borg_list {
+ my @archives;
+
+ run [qw(borg list)], '>', \my $output or die "borg list returned $?";
+
+ for (split/^/, $output) {
+ if (m/^([^\s]+)\s/) {
+ push @archives, $1;
+ }
+ }
+
+ return \@archives;
+}
+
+sub restore {
+ my $components_to_strip = shift;
+ my $archive_name = shift;
+ my $path = shift;
+
+ system(qw(borg extract -v --strip-components), $components_to_strip, "::".$archive_name, $path);
+}
+
+sub list_archive {
+ my $archive = shift;
+ my $fh = shift;
+
+ return start [qw(borg list --list-format), '{isomtime} {path}{NEWLINE}', "::".$archive], ">pipe", $fh;
+}
+
+1;
+
+__END__