CLOUDSTACK-5446: delete all the leftover snapshots on primary storage in case of snapshot errors, after a new backup snapshot is finished
(cherry picked from commit 2667855ccb932f9a03ddf6639f6411c73fea1b2c) Signed-off-by: Rohit Yadav <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/40bc5df0 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/40bc5df0 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/40bc5df0 Branch: refs/heads/4.4 Commit: 40bc5df0b1f82e5282521a869648b17c4af51558 Parents: 5e5d830 Author: Edison Su <[email protected]> Authored: Wed Nov 19 14:31:51 2014 -0800 Committer: Rohit Yadav <[email protected]> Committed: Thu Dec 11 20:52:06 2014 +0530 ---------------------------------------------------------------------- scripts/storage/qcow2/managesnapshot.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40bc5df0/scripts/storage/qcow2/managesnapshot.sh ---------------------------------------------------------------------- diff --git a/scripts/storage/qcow2/managesnapshot.sh b/scripts/storage/qcow2/managesnapshot.sh index 42bd1eb..6f13600 100755 --- a/scripts/storage/qcow2/managesnapshot.sh +++ b/scripts/storage/qcow2/managesnapshot.sh @@ -146,7 +146,8 @@ destroy_snapshot() { fi lvm lvremove -f "${vg}/${snapshotname}-cow" elif [ -f $disk ]; then - $qemu_img snapshot -d "$snapshotname" $disk + #delete all the existing snapshots + $qemu_img snapshot -l $disk |tail -n +3|awk '{print $1}'|xargs -I {} $qemu_img snapshot -d {} $disk >&2 if [ $? -gt 0 ] then failed=2
