On Tue, Jul 14, 2020 at 9:33 AM Łukasz Kołaciński <l.kolacinski@storware.eu> wrote:
Hello,

Hi Lukaz,

Lets move the discussion to devel@ovirt.org, I think it will be more productive.

Also, always CC me and Eyal on incremental backup questions for a quicker response.
 
I am trying to do full backup on ovirt 4.4 using sdk.

Which version of oVirt? libvirt?
 
I used steps from this youtube video: https://www.youtube.com/watch?v=E2VWUVcycj4 and I got error after running backup_vm.py. I see that sdk has imported disks and created backup entity and then I got sdk.NotFoundError exception.

This means that starting backup failed. Unfortunately the API does not have a good way to get
the error that caused the backup to fai.

You should be able to see the error in the event log in the UI, and in engine log.
 
I also tried to do full backup with API and after finalizing backup disappeared (I think)

So backup from the API was successful?

Backups are expected to disappear, they are temporary objects used to manage the backup
process. Once the backup process was finished you can do nothing with the backup object,
and you cannot fetch the same backup data again.
 
and I couldn't try incremental.

The fact that the backup disappeared should not prevent the next backup.

After you create a backup, you need to poll backup status until the backup is ready.

    while backup.phase != BackupPhase.READY:
        time.sleep(1)
        backup = backup_service.get()# to_checkpoint_id will be used as

If the backup does not end in ready state, it failed, and you cannot do anything with
this backup.

When the backup is ready, you can fetch the to_checkpoint_id created for this backup.

    checkpoint_id = backup.to_checkpoint_id

At this point you need to persist the checkpoint id. This will be used to create the incremental
backup.


[   0.0 ] Starting full backup for VM '51708c8e-6671-480b-b2d8-199a1af9cbdc'
Password:
[   4.2 ] Waiting until backup 0458bf7f-868c-4859-9fa7-767b3ec62b52 is ready
Traceback (most recent call last):
  File "./backup_vm.py", line 343, in start_backup
    backup = backup_service.get()
  File "/usr/lib64/python3.7/site-packages/ovirtsdk4/services.py", line 32333, in get
    return self._internal_get(headers, query, wait)
  File "/usr/lib64/python3.7/site-packages/ovirtsdk4/service.py", line 211, in _internal_get
    return future.wait() if wait else future
  File "/usr/lib64/python3.7/site-packages/ovirtsdk4/service.py", line 55, in wait
    return self._code(response)
  File "/usr/lib64/python3.7/site-packages/ovirtsdk4/service.py", line 208, in callback
    self._check_fault(response)
  File "/usr/lib64/python3.7/site-packages/ovirtsdk4/service.py", line 130, in _check_fault
    body = self._internal_read_body(response)
  File "/usr/lib64/python3.7/site-packages/ovirtsdk4/service.py", line 312, in _internal_read_body
    self._raise_error(response)
  File "/usr/lib64/python3.7/site-packages/ovirtsdk4/service.py", line 118, in _raise_error
    raise error
ovirtsdk4.NotFoundError: HTTP response code is 404.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./backup_vm.py", line 476, in <module>
    main()
  File "./backup_vm.py", line 173, in main
    args.command(args)
  File "./backup_vm.py", line 230, in cmd_start
    backup = start_backup(connection, args)
  File "./backup_vm.py", line 345, in start_backup
    raise RuntimeError("Backup {} failed".format(backup.id))
RuntimeError: Backup 0458bf7f-868c-4859-9fa7-767b3ec62b52 failed

This is correct, backup has failed.

Please check the event log to understand the failure.

Eyal, can you show how to get the error from the backup using the SDK, in a way
that can be used by a program?

e.g. a public error code that can be used to decide on the next step, and an error
message that can be used for displaying error to users of the backup application.

This should be added to the backup_vm.py example.

Nir