Add umount-all-backups

This commit is contained in:
Peter J. Holzer 2023-12-03 00:23:10 +01:00
parent 45095845fd
commit 3d78d4dd82
1 changed files with 14 additions and 0 deletions

14
scripts/umount-all-backups Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/perl
use v5.12;
use warnings;
chdir("/");
for my $backup_dir (glob("/backup/*")) {
next unless -f "$backup_dir/active";
say STDERR "unmounting $backup_dir";
system("/bin/umount", $backup_dir);
if ($backup_dir =~ m{(luks-[^/]+)}) {
say STDERR "closing $1";
system("/sbin/cryptsetup", "close", $1)
}
}