Backup file/folder during upgrade

Discover(request) our samples to help you get started with your project.
Post Reply
Dan
Posts: 4458
Joined: Wed Apr 24, 2013 3:51 pm

Backup file/folder during upgrade

Post by Dan » Sat Mar 31, 2018 11:41 am

Hello,

There might be cases when you need to backup specific file/folder during an upgrade.

To back up some files during an upgrade, you need to create a custom action. There will be two custom actions, first custom action will back up the config file before the old version being removed and another custom action that will restore the backuped files after the installation of the upgraded version.

An upgrade installation consists in two parts:
  • the uninstall of the old product version
  • the installation of the new product version
First custom action that will backup the config files needs to be added before the RemoveExistingProducts standard action, as you can see below:
backupConfigFilesDuringUpgrade.png
backupConfigFilesDuringUpgrade.png (29.27 KiB) Viewed 30547 times
The standard actions used by Advanced Installer can be revealed using the "Show Standard Action" button on the toolbar of the "Custom Actions" page.

The second custom action that will restore the config files needs to be scheduled after the "Add Resources" action group, as you can see below:
RestoreBackupFiles.png
RestoreBackupFiles.png (29.99 KiB) Viewed 30547 times
For example, you can create your custom action as a custom action written in C# or a custom action written in C++. Please take a look on the How to integrate and debug custom actions? article which may be useful to you.

If you will use the DTC C# approach, then you can take advantage of the Directory.Exists Method. You can also take a look on the How to backup and restore files/folders in APPDIR? thread which debates a similar issue.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

ahmedm3
Posts: 1
Joined: Mon Sep 07, 2020 10:24 am

Re: Backup file/folder during upgrade

Post by ahmedm3 » Mon Sep 07, 2020 10:28 am

Hi Dan,

i hope you are doing well. i found this very helpful as i wanted to do the same steps for my installers but unfortunately im not able to see this custom action "BackupConfigFilesDuringUpgrade".
can you please help if its updated or renamed. im using AI version 15.7

Thanks & Regards
Sultan Ahmed

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

Re: Backup file/folder during upgrade

Post by Catalin » Mon Sep 07, 2020 2:21 pm

Hello Ahmed and welcome to Advanced Installer forums,

Please note that my colleague Danut only gave the steps necessary to implement the custom action in Advanced Installer.

However, the custom action used by him is a dummy one. We do not currently have such predefined custom action in Advanced Installer.

As it can be seen, he has mentioned that it is up to the user to create the custom action:
For example, you can create your custom action as a custom action written in C# or a custom action written in C++. Please take a look on the How to integrate and debug custom actions? article which may be useful to you.
For instance, a way to backup your file would be:

- first copy the config file to a temporary location (e.g. the %temp% folder) --> this would be your first custom action

- after the files are installed, copy the config file from the temporary location back to the APPDIR folder --> this would be your second custom action

Hope this helps.

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

Post Reply