summaryrefslogtreecommitdiffstats
path: root/borg-restore.pl
diff options
context:
space:
mode:
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");