On Fri, May 6, 2022 at 4:24 AM David White via Users <users@ovirt.org> wrote: > > So perhaps qemu-img isn't the best way to do this. > I was hoping I could write a bash script or something to take a snapshot. Is > that possible, or is there a better way? > > I was looking at https://github.com/wefixit-AT/oVirtBackup tonight, but > haven't been able to get it to work as of yet. > > When I run it, it recognizes the backup storage domain, says that it has > started taking a snapshot, but then immediately says the snapshot was created > (at which point everything else fails): > > 2022-05-05 21:05:35,453: Start backup for: my-vm-name.example.com > 2022-05-05 21:05:35,554: The storage domain SpinningData is in state active > 2022-05-05 21:05:35,732: Snapshot creation started ... > 2022-05-05 21:05:35,732: Snapshot created > 2022-05-05 21:05:40,773: !!! No snapshot found !!! > 2022-05-05 21:05:40,773: All backups done > 2022-05-05 21:05:40,773: Backup failured for: > 2022-05-05 21:05:40,773: my-vm-name.example.com > 2022-05-05 21:05:40,773: Some errors occured during the backup, please check > the log file > > The README says something about the python-sdk. How do I install that? I > don't see that anywhere. > > [root@phys1 oVirtBackup-master]# yum info ovirt-engine-sdk-python > Updating Subscription Management repositories. > Last metadata expiration check: 1:14:19 ago on Thu 05 May 2022 07:58:16 PM > EDT. > Error: No matching Packages to list > [root@phys1 oVirtBackup-master]# yum whatprovides ovirt-engine-sdk-python > Updating Subscription Management repositories. > Last metadata expiration check: 1:14:31 ago on Thu 05 May 2022 07:58:16 PM > EDT. > Error: No Matches found
Maybe the backup solution you tried works only with CentOS 7 and python 2.7? For CentOS Stream 8, the package name is python3-ovirt-engine-sdk4. > Is there a better way to run automated backups than this approach and/or > using qemu-img? The best way to backup is to use one of the backup applications supporting the incremental backup API with oVirt 4.4+. If you want to develop your own solution, you can start with the backup_vm.py example in the python sdk. If you install python3-ovirt-engine-sdk4 on a CentOS Stream 8 host you have backup_vm.py script at: /usr/share/doc/python3-ovirt-engine-sdk4/examples/backup_vm.py This script can create full and incremental backups for VM disks. To use this script (and other scripts like upload_disk.py, download_disk.py) you need to create a ovirt.conf file: $ cat ~/.config/ovirt.conf [myengine] engine_url = https://myengine.mydomain username = admin@internal password = mypassword cafile = /etc/pki/vdsm/certs/cacert.pem You can create a full backup using: /usr/share/doc/python3-ovirt-engine-sdk4/examples/backup_vm.py \ -c myengine \ full \ --backup-dir /backups/vm-id \ vm-id This creates a files like: /backups/vm-id/{timestamp}.{checkpoint-id}.{disk-id}.full.qcow2 This file contains the contents of the disk disk-id at the time the backup was started, including data from all snapshots. The next backup can be incremental backup, using the checkpoint id of the previous backup: /usr/share/doc/python3-ovirt-engine-sdk4/examples/backup_vm.py \ -c myengine \ incremental \ --backup-dir /backups/vm-id \ --from-checkpoint-uuid checkpoint-id-1 \ vm-id This creates a file like: /backups/vm-id/{timestamp}.{checkpoint-id}.{disk-id}.incremental.qcow2 Using the previous backup as a backing file: /backups/vm-id/{timestamp}.checkpoint-id-1.{disk-id}.full.qcow2 The next backup will use this incremental backup as a backing file. This creates a chain of qcow2 images that can be used to restore the VM disks using any image in the chain. Note that the script does not backup the VM configuration. To restore the VM with the same configuration at the time of the backup you need to get the VM configuration and store it, and use it when restoring the VM. Unfortunately we don't have example code for this yet. You may also use the backup library in the ovirt-stress project. It is a simple library with the same features of the backup_vm.py script, with additional features like verifying backups with checksums. https://gitlab.com/nirs/ovirt-stress/-/blob/master/backup/backup.py You can see how this library is used in the stress test: https://gitlab.com/nirs/ovirt-stress/-/blob/master/backup/test.py#L130 > Sent with ProtonMail secure email. > > ------- Original Message ------- > On Wednesday, May 4th, 2022 at 1:27 PM, David White via Users > <users@ovirt.org> wrote: > > I've recently been working with the qemu-img commands for some work that has > nothing to do with oVirt or anything inside an oVirt environment. > > But learning and using these commands have given me an idea for automating > backups. > > I believe that the following is true, but to confirm, would the qemu-img > commands be available on the oVirt hosts to take VM snapshots and disk images? qemu-img is available on a host since vdsm uses it for storage operations like copying disks, creating snapshots, creating and copying bitmaps, and measuring disks. While qemu-img is required to create backups, it cannot create backup itself. Creating backup requires orchestration of multiple components in oVirt. Using the backup API is the best way to do this. Nir _______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-le...@ovirt.org Privacy Statement: https://www.ovirt.org/privacy-policy.html oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/RHZNMNMC3BQE57YGGHMLMKIXJ5FFUWBC/