Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions scripts/vm/hypervisor/kvm/nasbackup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ sanity_checks() {
log -ne "Environment Sanity Checks successfully passed"
}

verify_backup() {
local backup_dir="$1"
local failed=0
for img in "$backup_dir"/*.qcow2; do
[[ -f "$img" ]] || continue
if ! qemu-img check "$img" > /dev/null 2>&1; then
Comment on lines +90 to +92
echo "Backup verification failed for $img"
Comment on lines +87 to +93
log -ne "Backup verification FAILED: $img"
Comment on lines +92 to +94
failed=1
else
log -ne "Backup verification passed: $img"
fi
done
if [[ $failed -ne 0 ]]; then
echo "One or more backup files failed verification"
exit 1
fi
}

### Operation methods ###

backup_running_vm() {
Expand Down Expand Up @@ -114,6 +133,8 @@ backup_running_vm() {
rm -f $dest/backup.xml
sync

verify_backup "$dest"

# Print statistics
virsh -c qemu:///system domjobinfo $VM --completed
du -sb $dest | cut -f1
Expand All @@ -136,6 +157,8 @@ backup_stopped_vm() {
done
sync

verify_backup "$dest"

ls -l --numeric-uid-gid $dest | awk '{print $5}'
}

Expand Down
Loading