Thursday, April 26, 2012
How to take backups within InnoSetup
One of the important requirements for any software installer is to be able to take a backup of the system before new code is updated. Once code is updated, there must be a rollback (or uninstall procedure) as well. The installer must be able to place the code backup in a place where it can easily pick up code from when uninstalled. For software patches where several patches can be installed successively, this can get fairly complex since we only want to rollback specific code which is associated with the patch.
Taking code backups and doing a rollback is not an inbuilt feature in InnoSetup. However, with some customization, this can be easily achieved.
To backup code, a line very similar to code installation can be created when the installer is first created. For example:
Source: {app}\*; DestDir: "{#InstallHomeDir}\UnInstall{#MyAppVersion}\Websites"; Components: Core; Flags: {#UninstallFlags}; Check:TakeBackup;
This line is similar to a code install line, except it copies code from the application folders on the target machine to a pre-determined backup location. So this line only fires at run-time when code is being installed. For each "Source" line in the installer for code installation, there will be a matching line for backup similar to the one above. Note that a version number is included inside the DesDir to handle multiple patch scenarios. A Check is also used to turn backups on or off.
Once the backup is done, at un-install time, you can fire the following command from within Inno Setup:
Exec('xcopy', ExpandConstant('"{#InstallHomeDir}\UnInstall{#MyAppVersion}\Websites" "{app}" /f /c /v /e /r /h /y'), '',SW_SHOW, ewWaitUntilTerminated, ResultCode)
This will copy ALL your folders you have backed up to the {app} folder.
About Tukeys
Tukeys provides consulting and software services to companies in healthcare and communications that are dealing with technical or scaling challenges. Please reach out to me on LinkedIn.
An interesting quite from John Tukey, who was an American mathematician (1915-2000) -
An approximate answer to the right problem is worth a good deal more than an exact answer to an approximate problem.
Today maths and statistics form the basis of how software is developed and used around us.
About Me
I have over 20 years of experience in healthcare, communications and AI.
I have a passion for defining innovative applications, creating product/technology strategy and solving challenging problems. My product mindset is helpful to any company to find patterns, reduce costs, and gain efficiencies.
I was the VP of Engineering at Vibrent Health, where I led the web, mobile, API and data products that supported one of the largest NIH programs - All of Us Research Program. Our system enrolled almost a million users and collected data from EHRs, surveys and wearables. Before that, I worked at hCentive, a pioneer in health exchanges.
As the CTO of 3CLogic, I helped create the first PC and web-only contact center solution that implemented PBX and CRM functionality as an affordable SaaS solution. As the Chief Architect of NexTone, I was instrumental in the development of SIP and SIP based products. SIP and associated protocols form the basis of modern WebRTC APIs.
If you are a growth company or invest in growing companies that are facing technical or scaling challenges, I can be a tremendous help. Contact me on LinkedIn.
Featured Post
Random Forest Analysis of U.S. National Epidemiological Survey on Alcohol and Related Conditions (NESARC) data
In 2001/2002, the National Institute on Alcohol Abuse and Alcoholism (NIAAA) conducted the National Epidemiologic Survey on Alcohol and Re...