Backup file/folder during upgrade

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

Backup file/folder during upgrade

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


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 (29.27 KiB) Viewed 19244 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 (29.99 KiB) Viewed 19244 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 Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Post Reply