nasbackup.sh: add timeout, cleanup trap, space check, quiesce support#12843
Open
jmsperu wants to merge 1 commit intoapache:4.20from
Open
nasbackup.sh: add timeout, cleanup trap, space check, quiesce support#12843jmsperu wants to merge 1 commit intoapache:4.20from
jmsperu wants to merge 1 commit intoapache:4.20from
Conversation
…ror handling - Add BACKUP_TIMEOUT (default 6h) to prevent indefinitely stuck backup jobs; aborts via domjobabort when exceeded - Add EXIT trap with cleanup() that resumes paused VMs, removes temp dirs, and unmounts NFS on any exit (error, signal, or normal) - Add check_free_space() pre-flight check (default 1 GB minimum) - Add -q/--quiesce flag for optional fsfreeze/thaw via qemu-guest-agent - Use set -eo pipefail for stricter error handling - Fix mount_operation: proper if/then instead of broken $? after pipe - Quote all variable expansions to prevent word splitting - Remove manual umount/rmdir from functions (handled by trap) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1728663 to
937e646
Compare
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
BACKUP_TIMEOUT(default 6 hours) to prevent indefinitely stuck backup jobs; aborts viadomjobabortwhen exceededEXITtrap withcleanup()that resumes paused VMs, removes temp dirs, and unmounts NFS on any exit (error, signal, or normal) — prevents orphan mounts from accumulatingcheck_free_space()pre-flight check (default 1 GB minimum) before writing backup data-q/--quiesceflag for optionalfsfreeze/thawvia qemu-guest-agent for application-consistent backupsset -eo pipefailfor stricter error handlingmount_operation(): properif mountinstead of broken$?check after pipeumount/rmdirfrom functions (now handled by trap)Motivation
The current
nasbackup.shhas several reliability issues observed in production:until domjobinfo --completed) runs forever if backup stalls, blocking the agent/tmp/csbackup.XXXXX) and paused VMs that never resume (related: KVM NAS backup: VM remains paused indefinitely when backup job fails #12821)$?after a pipe always returns the pipe's exit status, not the command'sTest plan
BACKUP_TIMEOUT=30— verify timeout anddomjobabort-qflag and qemu-guest-agent installed — verify fsfreeze/thaw in logs-qflag without qemu-guest-agent — verify graceful fallback