I have Basic MSI Project that installs some files, Windows services, and it also runs SQL scripts.

First SQL script runs during Install and it creates DB backup file.
Second SQL script runs during Rollback and it restores DB from backup file.

The SQL Install (DB Backup) script runs during initial install and every time there is minor update.

Here is the problem:

1. User runs minor update for my product
2. Update fails before the SQL install action (i.e. before DB Backup)
3. SQL Rollback action is executed anyway and restores old backup file
4. Uses loses a lot of data

I tried adding Custom Action to Set Property (flag) to 1 after SQL Install action and then using that property as a condition in SQL Rollback script.
However, SQL script is executed as deferred and Set Property is executed as immediate, so my property is always set.

Am I doing it wrong? What else can I do to make SQL Rollback action be dependent on associated SQL Install action?

Thank you,