Skip to content

Instantly share code, notes, and snippets.

@nitmir
Created March 2, 2015 16:21
Show Gist options
  • Save nitmir/fd1041fbeef24e7f30ac to your computer and use it in GitHub Desktop.
Save nitmir/fd1041fbeef24e7f30ac to your computer and use it in GitHub Desktop.
Backup all luks header
#!/bin/bash
function backupdev () {
DEV=$1
if cryptsetup isLuks $DEV 2>/dev/null; then
DEVNAME=$(basename $DEV)
echo "Backup $DEV"
cryptsetup luksHeaderBackup $DEV --header-backup-file "luksHeaderBackup_${HOSTNAME}_${DEVNAME}.bin"
fi;
}
for dev in $(lshw -quiet -short -class disk -class volume | awk '{print $2}'); do
backupdev $dev
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment