#!/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) } }