cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mmyaseen
Level 4

Backup and Restore Database and files

Hi,

How can I backup and Restore MySQL Database and files while doing a major upgrade?

Regards
Yaseen D M
Labels (1)
0 Kudos
(8) Replies
cbragg
Level 7

This is really more of an administrators job and I would be tempted to leave this out of the installation. Mainly because the backup might not have space and it might need to be burnt to external drive a dvd or whatever.

Create a good guide and a dialoge warning the administrator to make this backup before proceeding

But if you need to do it you'll need to create your own sql script or vbscript conditioned to run on upgrade
0 Kudos
mmyaseen
Level 4

The problem with me is i created a major upgrade.

I have to retain the database and the data in it since based on some rule the tables are getting created and data is stored in those tables. and also i have to update the database with some default data required for Major upgrade after restoring the database. Major upgrade uninstalls the previous version product and installs the new version. while uninstalling the installer drops the database as per the rule set in the SQL Script option since we want to drop the database if the user tries to uninstall the product manually.

Is there any alternative for this?

Regards
0 Kudos
cbragg
Level 7

Ok i think maybe you should look into how to prevent the db from dropping on upgrade. Before we can answer that we need to know what type of project you are using
0 Kudos
mmyaseen
Level 4

I am using Basic MSI Project
0 Kudos
cbragg
Level 7

Ok I think I understand what's going on, I was in a similar position to you with one of my packages too.

The problem is that you most likely have created a drop database script for uninstall purposes and so you ticked the option 'run script during uninstall' The problem is, that also runs during a major upgrade. What you needed to do was in the same screen as 'run script during uninstall' there is an option to specify a conditional statement. And there you should have put Not UPGRADINGPRODUCTCODE UPGRADINGPRODUCTCODE is just a property that's created to show the product code of the product that is upgrading it but we just want to check it's existance to determine if it's just plain being uninstalled or whether it's being uninstalled as part of an upgrade.

Now the problem you have now, is that you need to add that to the product that is already installed. Not you current release. With database installation, patching is not always an option because you don't want your scripts running again. What you need to do is to modify a copy of your previous installation and then in your current installation, as a custom action you need to replace the cache copy so that it can uninstall correctly. Here is the script i created to do that (note that i store the cached version in the support files):

Option Explicit
On Error Resume Next
Const strProductCode = "{0366564F-64AE-44E8-8F4B-098D2C22231C}"
Dim objInstaller: Set objInstaller = CreateObject("WindowsInstaller.Installer")
Dim strMSICacheFile: strMSICacheFile = objInstaller.productInfo(strProductCode, "LocalPackage")
Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile Session.Property("SUPPORTDIR") & "\MyPatchedPackage.MSI", strMSICacheFile, True

You need to make sure that this runs before the RemoveExistingProducts action

Good luck 🙂
0 Kudos
mmyaseen
Level 4

I didn't understand this script. Does this stops the uninstallation of Database? or i have to handle the uninstallation of database here?

Can you please explain exactly what this script does?

If this is the complete script to handle the databas uninstallation then i tried but still the database gets deleted.
0 Kudos
mmyaseen
Level 4

I got it working with the help of following forum

http://www.symantec.com/connect/forums/retaining-data-and-upgradingproductcode-major-upgrade

Thanx for your gr8 help it really helped me a lot in finding the problem and the solution, I have more idea about Uninstall process handling from Installshield now.

Thanx and Regards
Yaseen D M
0 Kudos
cbragg
Level 7

Ok sorry if i was misleading, i'll take it from the start. In your previous version's MSI you must have a SQL script that you use to drop (delete) the database on uninstall. You should be able to see this in the SQL scripts view if you still have the original project otherwise you'll have to look at the raw tables in the MSI that deal with sql scripts.

When you installed your previous version, windows installer caches that msi on the PC for use in repairs and uninstalls etc... Now your new upgrade comes along, finds the old version installed on the pc and performs and upgrade. To do this.. it runs the uninstall from the cached copy before it installs from your version.

So hopefully now you can see what happened during the upgrade.. Your uninstall of the old version probably kicked off a delete (drop) database script, then your new one comes and installs a fresh copy, or even worse, runs an upgrade script on a missing database.

The problem you have is that this bug doesn't exist in your current version, it exists in the previous version that's already cached and installed on the pc. You could create a patch for this product before you upgrade but this tends not to work too well for db installers in my experience because they need to be rerun. So what you need to do is get a copy of the previous installation, find the script that is dropping the database and set a condition on it so that it only uninstalls if you are doing a complete uninstall and not just upgrading it. The condition to do this is: Not UPGRADINGPRODUCTCODE.

Now you need to replace the cache copy with the new modified copy so that when your product calls the uninstall of the old one it actually calls the modified one with the bug fix instead.

To do this you need to put the previous modified MSI into your current installer so that it can drop it down to the machine's cache before it tries to uninstall using it. Simply place the modified msi into your current msi's support files. Then the script i sent you will place your previous bug fixed msi into the machine's cache. The script needs to run as a custom action before the RemoveExistingProducts action (the action that will perform the uninstall)

Please note the script needs to be modified so that it contains the correct product code of your previous version and the name of your previous bug fixed msi.

Please also note that the condition will need to be set in this version of your msi too so that this doesn't happen again in the next upgrade.
0 Kudos