diff options
author | Florian Pritz <bluewind@xinu.at> | 2016-08-15 18:04:39 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2016-08-15 18:04:39 +0200 |
commit | 672b807112fedaa0b8f3287a8d2a4790c787f622 (patch) | |
tree | a669070ced99664ff560ca28894c330a89b57dce | |
parent | 45df6cefcbdf23758a0d9ab7fd707d8a622339b1 (diff) | |
download | bin-672b807112fedaa0b8f3287a8d2a4790c787f622.tar.gz bin-672b807112fedaa0b8f3287a8d2a4790c787f622.tar.xz |
borg-restore.pl: Support multiple backup prefixes
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-x | borg-restore.pl | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/borg-restore.pl b/borg-restore.pl index 39f1048..116d9de 100755 --- a/borg-restore.pl +++ b/borg-restore.pl @@ -103,7 +103,11 @@ use Time::HiRes; my %opts; my %db; my $cache_path_base = "/home/flo/.cache/borg-restore.pl"; -my $backup_prefix = "/"; +my @backup_prefixes = ( + {regex => "^/home/", replacement => "mnt/snapshots/vg0-homeborg/"}, + {regex => "^/boot/", replacement => ""}, + {regex => "^/", replacement => "mnt/snapshots/vg0-rootborg/"}, +); sub debug { say STDERR @_ if $opts{debug}; @@ -640,7 +644,12 @@ sub main { $destination = dirname($abs_path); } my $backup_path = $abs_path; - $backup_path =~ s/^\Q$backup_prefix\E//; + for my $backup_prefix (@backup_prefixes) { + if ($backup_path =~ m/$backup_prefix->{regex}/) { + $backup_path =~ s/$backup_prefix->{regex}/$backup_prefix->{replacement}/; + last; + } + } debug("Asked to restore $backup_path to $destination"); |