Skip to content

Commit

Permalink
(#4) save image info before starting backup
Browse files Browse the repository at this point in the history
  • Loading branch information
abbbi committed Jan 28, 2024
1 parent 330b93a commit 54020f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
13 changes: 13 additions & 0 deletions libqmpbackup/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ def get_info(filename):
except subprocess.CalledProcessError as errmsg:
raise RuntimeError from errmsg

def save_info(backupdir, blockdev):
"""Save qcow image information"""
for dev in blockdev:
infofile = f"{backupdir}/{dev.node}.config"
try:
info = get_info(dev.filename)
except RuntimeError as errmsg:
log.warning("Unable to get qemu image info: [%s]", errmsg)
continue
with open(infofile, "wb+") as info_file:
info_file.write(info)
log.info("Saved image info: [%s]", infofile)


def rebase(directory, dry_run, until):
"""Rebase and commit all images in a directory"""
Expand Down
13 changes: 2 additions & 11 deletions qmpbackup
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ async def main():

log.info("Backup target directory: %s", backupdir)

image.save_info(backupdir, blockdev)

qga = False
if argv.agentsocket and argv.quiesce:
qga = lib.connect_qaagent(argv.agentsocket)
Expand All @@ -331,17 +333,6 @@ async def main():
fs.thaw(qga)
sys.exit(1)

for dev in blockdev:
infofile = f"{backupdir}/{dev.node}.config"
try:
info = image.get_info(dev.filename)
except RuntimeError as errmsg:
log.warning("Unable to get qemu image info: [%s]", errmsg)
continue
with open(infofile, "wb+") as info_file:
info_file.write(info)
log.info("Saved image info: [%s]", infofile)

if argv.level == "copy":
blockdev = vm.get_block_devices(
await qemu_client.do_query_block(), excluded_disks, included_disks
Expand Down

0 comments on commit 54020f7

Please sign in to comment.