diff options
author | Florian Pritz <bluewind@xinu.at> | 2017-04-02 22:30:42 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2017-04-02 22:31:49 +0200 |
commit | c95c28f70cca499ad8b8c88ddb380bb81570ddf6 (patch) | |
tree | a9193a3ff2aa4ac9cad6abec1cc74c883c6508c6 /lib/App | |
parent | 3301b7ac5b454845d6c33f3d311fbf3fd0d44f6f (diff) | |
download | App-BorgRestore-c95c28f70cca499ad8b8c88ddb380bb81570ddf6.tar.gz App-BorgRestore-c95c28f70cca499ad8b8c88ddb380bb81570ddf6.tar.xz |
Add restore_simple
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/App')
-rw-r--r-- | lib/App/BorgRestore.pm | 25 |
1 files changed, 25 insertions, 0 deletions
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; |