1

Hello I made a backup of a VM guest with these steps:

1. virsh dumpxml --migratable test > /backup/test.xml

2. virsh snapshot-create-as --domain test   \
                         --name backup.qcow2 \
                         --no-metadata       \
                         --atomic            \
                         --quiesce           \
                         --disk-only         \
                         --diskspec vda,snapshot=external

3. cp /var/lib/libvirt/images/test.qcow2 /backup/
4. virsh blockcommit test vda --active --pivot
5. rm -f /var/lib/libvirt/images/test.backup.qcow2

After backup I am trying to test if I can restore from it.

  1. I am shutting down guest 'test'
  2. Undefying guest 'test'
  3. removing qcow2 image from main images folder
  4. then copy qcow2 to main image folder
  5. Trying to define by this command:

virsh define -file /backup/test.xml

and I am getting error: error: unexpected data 'test.xml'

What I am doing wrong? How can I troubleshot this?

andys
  • 113
  • 5

3 Answers3

1

When you get an error suggesting a syntax problem, you should always check the man page first.

virsh define expects only one argument, the filename from which it should load the XML definition. You have passed two arguments. Thus it thinks you are trying to load a file named -file, and has no idea what you mean with the second argument test.xml.

The correct syntax is virsh define filename.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
1

The problem with your virsh define is, as Hampton said, you should either remove the option -file, or if you want to keep it, it should be double hyphen, not a single one. So, it should be --file.

0

It works both ways:

virsh define --file /backup/test.xml

or

virsh define /backup/test.xml
mBesar
  • 1