From 7c57304926fe0e8f20e951895746ffcdfd557dc4 Mon Sep 17 00:00:00 2001 From: ma Date: Mon, 21 Oct 2024 11:10:04 +0200 Subject: [PATCH] .. --- libqmpbackup/image.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libqmpbackup/image.py b/libqmpbackup/image.py index d083830..e24e00e 100644 --- a/libqmpbackup/image.py +++ b/libqmpbackup/image.py @@ -322,12 +322,11 @@ def snapshot_rebase(argv): if argv.until is not None: sidx = images_flat.index(argv.until) - print(images[1:]) snapshot_cmd = f'qemu-img snapshot -c "FULL-BACKUP" "{images[0]}"' + log.info(snapshot_cmd) try: if not argv.dry_run: - # subprocess.check_output(snapshot_cmd, shell=True) - log.info(snapshot_cmd) + subprocess.check_output(snapshot_cmd, shell=True) except subprocess.CalledProcessError as errmsg: log.error("Rebase command failed: [%s]", errmsg) return False @@ -353,7 +352,7 @@ def snapshot_rebase(argv): try: snapshot_cmd = ( - f'qemu-img snapshot -c "INC-{os.path.basename(image[idx])}" "{image}"' + f'qemu-img snapshot -c "{os.path.basename(image)}" "{images[0]}"' ) log.info(snapshot_cmd) rebase_cmd = ( @@ -363,12 +362,16 @@ def snapshot_rebase(argv): commit_cmd = "qemu-img commit -b " f'"{images[0]}" ' f'"{image}"' log.info(commit_cmd) # subprocess.check_output(commit_cmd, shell=True) - # if not argv.dry_run: - # subprocess.check_output(snapshot_cmd, shell=True) - # subprocess.check_output(rebase_cmd, shell=True) - # subprocess.check_output(commit_cmd, shell=True) + if not argv.dry_run: + subprocess.check_output(snapshot_cmd, shell=True) + subprocess.check_output(rebase_cmd, shell=True) + subprocess.check_output(commit_cmd, shell=True) except subprocess.CalledProcessError as errmsg: log.error("Rebase command failed: [%s]", errmsg) return False + if not argv.dry_run: + log.info("Removing: [%s]", image) + os.remove(image) + return True