Andromeda
Posts: 3
Joined: Wed Nov 06, 2019 10:41 pm

Backing up Database file when Upgrading a Program

Hey all
I am trying to create MST file that will back up the database file for the program so it is not overwritten when upgrading the app. I tried adding in custom actions, Launch Attached File, before Preparing and after Add Resources. These files consist of simple a simple .bat that moves the db file to the temp folder, then back again, but so far it does not seem to be working. Is there a better way to accomplish this? I'm new to Advanced Installer and any assistance would be greatly appreciated


Cheers
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Backing up Database file when Upgrading a Program

Hello and welcome to Advanced Installer forums,

First of all, please accept my apologies for the delayed reply.

In what regards the database file, is it delivered with the setup or is it created at install time (for instance, by an SQL script)?

If it is delivered with the setup, you can go to "Files and Folders" page --> right click on the database file --> "Properties" --> "Operations" tab --> select the "Do not overwrite existing file" and set the "Condition" field to "OLDPRODUCTS" (without quotes).

The OLDPRODUCTS property represents a list with the Product Codes of the older versions of your installation package. This property is set only in a package which upgrades another package.

If this is not the case, then indeed, you may need a custom approach (e.g. a custom action as you've earlier mentioned). Does the custom action that is added after the "Add Resources" action group have its execution time set to "When the system is being modified (deferred)"? This is really important as the resources are removed/added on the deferred stage. Let's have a look on the following sample so you can better understand:

Let's consider the following actions:

Action1 - Immediate execution time
Action2 - Immediate execution time
Action3 - Deferred execution time
Action4 - Immediate Execution time

Basically, the order of execution of the above actions is: Action1 --> Action2 --> Action4 --> Action3

As you can see, the deferred is executed after. On a more specific sample:

YourCustomAction - Immediate
RemoveResources - Deferred
AddResources - Deferred
YourCustomAction2 -

If YourCustomAction2 is set on to run on Immediate, it will basically copy the database file to a destination then copy it back and then when the "RemoveResources" action group will execute, the file will be deleted (as explained above in the execution example). If the second custom action is set to execute during the Deferred stage, then it will execute after the "AddResources" action group, therefore it should succeed.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”