diff options
author | Florian Pritz <bluewind@xinu.at> | 2017-04-02 22:07:56 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2017-04-02 22:31:49 +0200 |
commit | 286751abf9661a93d3d1de53df98c06ea4c3ddb7 (patch) | |
tree | ddbc335e505efd891f64e8bda60895107b5fdf75 | |
parent | 7988bf4796a63c0fa233e7b462b58612cc90bb42 (diff) | |
download | App-BorgRestore-286751abf9661a93d3d1de53df98c06ea4c3ddb7.tar.gz App-BorgRestore-286751abf9661a93d3d1de53df98c06ea4c3ddb7.tar.xz |
Call borg with repo path instead of setting BORG_REPO
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | lib/App/BorgRestore.pm | 2 | ||||
-rw-r--r-- | lib/App/BorgRestore/Borg.pm | 9 | ||||
-rwxr-xr-x | script/borg-restore.pl | 2 |
3 files changed, 7 insertions, 6 deletions
diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm index 90b7d61..e039011 100644 --- a/lib/App/BorgRestore.pm +++ b/lib/App/BorgRestore.pm @@ -85,7 +85,7 @@ sub new { my $db_path = App::BorgRestore::Settings::get_db_path(); - $self->{borg} = $deps->{borg} // App::BorgRestore::Borg->new(); + $self->{borg} = $deps->{borg} // App::BorgRestore::Borg->new($App::BorgRestore::Settings::borg_repo); $self->{db} = $deps->{db} // App::BorgRestore::DB->new($db_path); return $self; diff --git a/lib/App/BorgRestore/Borg.pm b/lib/App/BorgRestore/Borg.pm index 8b4e953..38c12ae 100644 --- a/lib/App/BorgRestore/Borg.pm +++ b/lib/App/BorgRestore/Borg.pm @@ -7,10 +7,13 @@ use IPC::Run qw(run start new_chunker); sub new { my $class = shift; + my $borg_repo = shift; my $self = {}; bless $self, $class; + $self->{borg_repo} = $borg_repo; + return $self; } @@ -18,7 +21,7 @@ sub borg_list { my $self = shift; my @archives; - run [qw(borg list)], '>', \my $output or die "borg list returned $?"; + run [qw(borg list), $self->{borg_repo}], '>', \my $output or die "borg list returned $?"; for (split/^/, $output) { if (m/^([^\s]+)\s/) { @@ -35,7 +38,7 @@ sub restore { my $archive_name = shift; my $path = shift; - system(qw(borg extract -v --strip-components), $components_to_strip, "::".$archive_name, $path); + system(qw(borg extract -v --strip-components), $components_to_strip, $self->{borg_repo}."::".$archive_name, $path); } sub list_archive { @@ -43,7 +46,7 @@ sub list_archive { my $archive = shift; my $cb = shift; - open (my $fh, '-|', 'borg', qw/list --list-format/, '{isomtime} {path}{NEWLINE}', "::".$archive); + open (my $fh, '-|', 'borg', qw/list --list-format/, '{isomtime} {path}{NEWLINE}', $self->{borg_repo}."::".$archive); while (<$fh>) { $cb->($_); } diff --git a/script/borg-restore.pl b/script/borg-restore.pl index 48744e4..f42984e 100755 --- a/script/borg-restore.pl +++ b/script/borg-restore.pl @@ -239,8 +239,6 @@ sub main { # untaint PATH because we only expect this to run as root $ENV{PATH} = App::BorgRestore::Helper::untaint($ENV{PATH}, qr(.*)); - $ENV{BORG_REPO} = $App::BorgRestore::Settings::borg_repo unless $App::BorgRestore::Settings::borg_repo eq ""; - Getopt::Long::Configure ("bundling"); GetOptions(\%opts, "help|h", "debug", "update-cache|u", "destination|d=s", "time|t=s") or pod2usage(2); pod2usage(0) if $opts{help}; |