nasbackup.sh: add LUKS encryption for backup files via -e flag#12848
Open
jmsperu wants to merge 1 commit intoapache:4.20from
Open
nasbackup.sh: add LUKS encryption for backup files via -e flag#12848jmsperu wants to merge 1 commit intoapache:4.20from
jmsperu wants to merge 1 commit intoapache:4.20from
Conversation
Add -e/--encrypt flag that accepts a passphrase file path and encrypts all qcow2 backup files using LUKS encryption via qemu-img convert. The passphrase is read from a file (not command-line) to avoid exposure in process listings. Encryption is applied after backup completes, for both running and stopped VM backup paths. Encrypted backups use the standard qcow2+LUKS format supported by QEMU, so they can be decrypted with qemu-img or mounted directly by any QEMU/libvirt tooling that supports LUKS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-e/--encrypt <passphrase-file>flag that encrypts backup qcow2 files using LUKS encryptionqemu-img convertwith--object secretandencrypt.format=luks— standard qcow2+LUKS format/proc/*/cmdlineMotivation
NAS backup targets are often shared storage accessible to multiple hosts and administrators. Unencrypted VM disk backups on NFS expose sensitive data (databases, credentials, user files) to anyone with NFS access.
LUKS-encrypted qcow2 is the standard QEMU encryption format, supported by all QEMU/libvirt tooling. The passphrase file can be managed by CloudStack and stored securely on the agent host (e.g. in
/etc/cloudstack/agent/), separate from the backup data on NFS.Design
-eflag by the CloudStack agentencrypt_backup()iterates over all.qcow2files in the backup directoryqemu-img convert -O qcow2 --object secret ... -o encrypt.format=luks ...qemu-img convertTest plan
-e— verify no encryption, identical to current behavior-e /path/to/passphrase— verify qcow2 files are LUKS-encrypted (qemu-img infoshowsencrypted: yes)qemu-img convert --object secret ...— verify data integrity