From 3d78d4dd82b26dbe3307cd1384eaeef7111544df Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sun, 3 Dec 2023 00:23:10 +0100 Subject: [PATCH] Add umount-all-backups --- scripts/umount-all-backups | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 scripts/umount-all-backups diff --git a/scripts/umount-all-backups b/scripts/umount-all-backups new file mode 100755 index 0000000..e1882aa --- /dev/null +++ b/scripts/umount-all-backups @@ -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) + } +}