Recently, while testing backup scripts, I happened to notice that 'virsh
snaphot-create-as . . .' has been failing with 'error: failed to get
domain '$DOMAIN'' when run through crontab. So I've been unwittingly
backing up the live, running, QCOW2 images for quite some time because
scripts which run fine when testing from CLI, fail to work as expected
when run as a cron job.
After much searching, I stumbled upon a related issue with the
(obvious?) simple solution almost hidden in the answers. You have to
explicitly connect to the local server with, e.g.:
virsh -c qemu:///system snapshot-create-as . . .
Humble apologies if I missed something I should have been aware of, but
I just thought it worthwhile mentioning here for anyone else searching
for an answer in the archives.
Best regards,
Jeff