If you prefer full control inside the VM (or you want something more tailored per workload), following approach is to run a pre-snapshot script (quiesce), trigger the snapshot via API, then run a post-snapshot script (resume).
- Pre-snapshot (example)
#!/bin/bash
set -e
systemctl stop mysqld || true
sync
fsfreeze -f /data
2. Snapshot trigger (API example )
#!/bin/bash
VM_UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
curl -k -u 'apiuser:apipass' \
-H 'Content-Type: application/json' \
-X POST "https://<PRISM-IP>:9440/api/nutanix/v3/snapshots" \
-d '{
"spec": {
"resources": {
"entity_uuid": "'"$VM_UUID"'",
"snapshot_type": "CRASH_CONSISTENT"
},
"name": "snap-from-inside-'"$(date +%F-%H%M)"'"
}
}'
3. Post-snapshot (example)
#!/bin/bash
set -e
fsfreeze -u /data
systemctl start mysqld || true
This route can work well when you want custom quiescing logic, but it does add some moving parts (API auth/endpoint, error handling, timeouts, etc.).