From c95c28f70cca499ad8b8c88ddb380bb81570ddf6 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 2 Apr 2017 22:30:42 +0200 Subject: Add restore_simple Signed-off-by: Florian Pritz --- lib/App/BorgRestore.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib/App/BorgRestore.pm') diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm index e039011..2477fdf 100644 --- a/lib/App/BorgRestore.pm +++ b/lib/App/BorgRestore.pm @@ -34,6 +34,15 @@ App::BorgRestore - Restore paths from borg backups use App::BorgRestore; + my $app = App::BorgRestore->new(); + + # Update the cache (call after creating/removing backups) + $app->update_cache(); + + # Restore a path from a backup that is at least 5 days old. Optionally + # restore it to a different directory than the original. + $app->restore_simple($path, "5days", $optional_destination_directory); + =head1 DESCRIPTION App::BorgRestore is a restoration helper for borg. @@ -254,6 +263,22 @@ sub restore { $self->{borg}->restore($components_to_strip, $archive_name, $path); } +sub restore_simple { + my $self = shift; + my $path = shift; + my $timespec = shift; + my $destination = shift; + + my $abs_path = $self->resolve_relative_path($path); + my $backup_path = $self->map_path_to_backup_path($abs_path); + + $destination //= dirname($abs_path); + + my $archives = $self->find_archives($backup_path); + my $selected_archive = $self->select_archive_timespec($archives, $timespec); + $self->restore($backup_path, $selected_archive, $destination); +} + sub _add_path_to_hash { my $self = shift; my $hash = shift; -- cgit v1.2.3-24-g4f1b