abbbi / virtnbdbackup

Backup utility for Libvirt / qemu / kvm supporting incremental and differential backups + instant recovery (agentless).
http://libvirtbackup.grinser.de/
GNU General Public License v3.0
330 stars 46 forks source link

virtnbdbackup: checkpoint option doesn't seem to work #33

Closed skleijkers closed 2 years ago

skleijkers commented 2 years ago

Hi,

I'm trying to make differential backups against the full backup (checkpoint named virtnbdbackup.0) with the option --checkpoint virtnbdbackup.0, but although virtnbdbackup says it uses the virtnbdbackup.0 as parent it uses virtnbdbackup.1 (first incrementall) as parent.

Relevant part of the log output of the second incremental run: [2022-02-18 20:33:10] INFO common - printVersion [MainThread]: Version: 0.43 Arguments: /usr/bin/virtnbdbackup --domain X --level inc --output X --checkpoint virtnbdbackup.0 -n -v
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Backup level: [inc]
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Domain has 1 disks attached which support changed block tracking.
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Concurrent backup processes: [1]
[2022-02-18 20:33:10] INFO libvirthelper - redefineCheckpoints [MainThread]: Loading checkpoint list from: [X/checkpoints]
[2022-02-18 20:33:10] DEBUG libvirthelper - redefineCheckpoints [MainThread]: Loading checkpoint config from: [X/checkpoints/virtnbdbackup.0.xml]
[2022-02-18 20:33:10] DEBUG libvirthelper - redefineCheckpoints [MainThread]: Checkpoint [virtnbdbackup.0] found
[2022-02-18 20:33:10] DEBUG libvirthelper - redefineCheckpoints [MainThread]: Loading checkpoint config from: [X/checkpoints/virtnbdbackup.1.xml]
[2022-02-18 20:33:10] DEBUG libvirthelper - redefineCheckpoints [MainThread]: Checkpoint [virtnbdbackup.1] found
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Checkpoint handling
[2022-02-18 20:33:10] WARNING virtnbdbackup - main [MainThread]: Overriding parent checkpoint: virtnbdbackup.0
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Next checkpoint id: 2
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Parent checkpoint name virtnbdbackup.0
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Using checkpoint name: virtnbdbackup.2 [2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Temporary scratch file target directory: /var/tmp
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: NDB Endpoint socket: /var/tmp/virtnbdbackup.741704
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Starting backup job.

After the backup I ran virsh checkpoint-list X --tree and this is the output: virtnbdbackup.0 +- virtnbdbackup.1
  +- virtnbdbackup.2

Although I would expect the .2 checkpoint to be a child of the .0 checkpoint (the output got scrambled by the editor, but checkpoint .2 has .1 as parent and .1 has .0 as parent).

Futhermore the checkpoint xml states (in the checkpoint directory of the backup):

virtnbdbackup.2 Backup checkpoint virtnbdbackup.1 1645212791 Am I missing something or did I hit a bug? Kind regards, Stefan
abbbi commented 2 years ago

hm.. in my testing it looks like this:

1) full backup:

./virtnbdbackup -v -d vm1 -o /tmp/FF -l full

2) inc backup

./virtnbdbackup -v -d vm1 -o /tmp/FF -l inc

3) another inc backup with --checkpoint option:

./virtnbdbackup -v -d vm1 -o /tmp/FF -l inc --checkpoint virtnbdbackup.0 -v

the debug output shows the following xml beeing setup:

<domaincheckpoint>
  <description>Backup checkpoint</description>
  <name>virtnbdbackup.2</name>
  <parent>
    <name>virtnbdbackup.0</name>
  </parent>
  <disks>
    <disk name="sda" />
  </disks>
</domaincheckpoint>

so the crafted XML checkpoint XML that has been created is OK, but libvirt shows:

virsh checkpoint-list vm1 --parent
 Name              Creation Time               Parent
----------------------------------------------------------------
 virtnbdbackup.0   2022-02-19 14:36:36 +0100   
 virtnbdbackup.1   2022-02-19 14:36:50 +0100   virtnbdbackup.0
 virtnbdbackup.2   2022-02-19 14:37:12 +0100   virtnbdbackup.1

It might well be that the libvirt version in question desnt support this, if i create a custom xml file with checkpoint parent override its simply ignored:

virsh checkpoint-create --domain vm1 --xmlfile test.xml 
Domain checkpoint virtnbdbackup.3 created from 'test.xml'
 virsh checkpoint-list vm1 --parent
 Name              Creation Time               Parent
----------------------------------------------------------------
 virtnbdbackup.0   2022-02-19 14:36:36 +0100   
 virtnbdbackup.1   2022-02-19 14:36:50 +0100   virtnbdbackup.0
 virtnbdbackup.2   2022-02-19 14:37:12 +0100   virtnbdbackup.1
 virtnbdbackup.3   2022-02-19 14:43:32 +0100   virtnbdbackup.2
abbbi commented 2 years ago

I read the documentation again, and according to this the checkpoint parent option in the checkpoint xml is readonly:

parent
Readonly, present if this checkpoint has a parent. The parent name is given by the sub-element name. The parent relationship allows tracking a list of related checkpoints.

so actually, this option never behaved as i thought it woudl (and i never used it either), thus it cant be used to create differencial backups.

abbbi commented 2 years ago

New release with option removed until one figures how this feature would work to create differencial backups,but currently, it doesnt seem to behave the way i thought (at least not on libvirt shipped with debian11).

It seems its not even necessary to pass the parent option to the checkpoint definition anymore (it may have been a few years ago as i started having a look at this feature)