Skip to content

Commit

Permalink
add copy backup level
Browse files Browse the repository at this point in the history
  • Loading branch information
abbbi committed Jan 25, 2024
1 parent 220cead commit 731d9d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ consistency by creating the bitmap and backup within one QMP transaction.

Multiple disks attached to the virtual machine are backed up concurrently.

Bitmaps will be added with persistent option flag, which means they are stored
permanently and are available between virtual machine shutdowns.
During full and incremental backup, bitmaps will be created with `persistent
option flag`. This means QEMU attempts to store them in the QCOW images, so
they are available between virtual machine shutdowns. The attached QCOW images
must be in qcow(v3) format, for this to work.

If you cant convert your QCOW images to newer formats, you still can use the
backup mode `copy`: it allows to execute a complete full backup but no further
incremental backups.

Second step is to change some data within your virtual machine and let
*qmpbackup* create an incremental backup for you, this works by:
Expand Down
9 changes: 7 additions & 2 deletions libqmpbackup/qmpcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def prepare_transaction(self, devices, level, backupdir):
prefix = "INC"
sync = "incremental"

if level == "copy":
self.log.info("Copy backup: no bitmap will be created.")

actions = []
files = []
for device in devices:
Expand All @@ -64,14 +67,16 @@ def prepare_transaction(self, devices, level, backupdir):
if not device.has_bitmap and level == "full":
self.log.debug("Creating new bitmap")
actions.append(
self.transaction_bitmap_add(device.node, bitmap, persistent=True)
self.transaction_bitmap_add(
device.node, bitmap, persistent=True
)
)

if device.has_bitmap and level == "full":
self.log.debug("Clearing existing bitmap")
actions.append(self.transaction_bitmap_clear(device.node, bitmap))

if level == "full":
if level in ("full", "copy"):
actions.append(
self.transaction_action(
"drive-backup",
Expand Down
2 changes: 1 addition & 1 deletion qmpbackup
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async def main():
parser_backup.set_defaults(which="backup")
parser_backup.add_argument(
"--level",
choices=["full", "inc", "auto"],
choices=["copy", "full", "inc", "auto"],
type=str,
help="backup level",
required=True,
Expand Down

0 comments on commit 731d9d0

Please sign in to comment.