summaryrefslogtreecommitdiffstats
path: root/borg-restore.pl
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-08-15 18:04:39 +0200
committerFlorian Pritz <bluewind@xinu.at>2016-08-15 18:04:39 +0200
commit672b807112fedaa0b8f3287a8d2a4790c787f622 (patch)
treea669070ced99664ff560ca28894c330a89b57dce /borg-restore.pl
parent45df6cefcbdf23758a0d9ab7fd707d8a622339b1 (diff)
downloadbin-672b807112fedaa0b8f3287a8d2a4790c787f622.tar.gz
bin-672b807112fedaa0b8f3287a8d2a4790c787f622.tar.xz
borg-restore.pl: Support multiple backup prefixes
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'borg-restore.pl')
-rwxr-xr-xborg-restore.pl13
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");