backuptool: Ensure to cleanup the environment on failure

Change-Id: I6f974a40b4f3f4a0a1f3a4b46bf8e0cfeb81c4ec
This commit is contained in:
Alessandro Astone
2021-03-21 11:39:06 +01:00
committed by Bruno Martins
parent 271ba02664
commit b5f3a4a72d

View File

@@ -164,23 +164,30 @@ umount_extra() {
done done
} }
cleanup() {
umount_extra $all_V3_partitions
umount /postinstall/tmp
rm -rf /postinstall/tmp
}
case "$1" in case "$1" in
backup) backup)
if check_prereq; then if check_prereq; then
mkdir -p $C mkdir -p $C
preserve_addon_d preserve_addon_d
run_stages pre-backup backup post-backup run_stages pre-backup backup post-backup
else
cleanup
fi fi
;; ;;
restore) restore)
if check_prereq; then if check_prereq; then
run_stages pre-restore restore post-restore run_stages pre-restore restore post-restore
umount_extra $all_V3_partitions
restore_addon_d restore_addon_d
rm -rf $C cleanup
umount /postinstall/tmp
rm -rf /postinstall/tmp
sync sync
else
cleanup
fi fi
;; ;;
*) *)