Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating System Restore Points - Thoughts?

Is it "taboo" to programatically create system restore points? I would be doing this before I perform a software update. If there is a better method to create a restore point with just my software's files and data, please let me know.

I would like a means by which I can get the user back to a known working state if everything goes kaput during an update (closes/kills the update app, power goes out, user pulls the plug, etc.)

    private void CreateRestorePoint(string description)
    {
        ManagementScope oScope = new ManagementScope("\\\\localhost\\root\\default");
        ManagementPath oPath = new ManagementPath("SystemRestore");
        ObjectGetOptions oGetOp = new ObjectGetOptions();
        ManagementClass oProcess = new ManagementClass(oScope, oPath, oGetOp);

        ManagementBaseObject oInParams = oProcess.GetMethodParameters("CreateRestorePoint");
        oInParams["Description"] = description;
        oInParams["RestorePointType"] = 12; // MODIFY_SETTINGS
        oInParams["EventType"] = 100;

        ManagementBaseObject oOutParams = oProcess.InvokeMethod("CreateRestorePoint", oInParams, null); 
    }
like image 510
Nick Avatar asked Jan 24 '23 03:01

Nick


2 Answers

Is it "taboo" to programatically create system restore points?

No. That's why the API is there; so that you can have pseudo-atomic updates of the system.

like image 198
DrPizza Avatar answered Feb 11 '23 06:02

DrPizza


Whether it's a good idea or not really depends on how much you're doing. A full system restore point is weighty - it takes time to create, disk space to store, and gets added to the interface of restore points, possibly pushing earlier restore points out of storage.

So, if your update is really only changing your application (i.e. the data it stores, the binaries that make it up, the registry entries for it), then it's not really a system level change, and I'd vote for no restore point. You can emulate the functionality by just backing up the parts you're changing, and offering a restore to backup option. My opinion is that System Restore should be to restore the system when global changes are made that might corrupt it (application install, etc).

The counter argument that one should just use the system service doesn't hold water for me; I worry that, if you have to issue a number of updates to your application, the set of system restore points might get so large that important, real "system wide" updates might get pushed out, or lost in the noise.

like image 40
Adam Wright Avatar answered Feb 11 '23 06:02

Adam Wright