* Backup and Restore FH Settings via Windows - new plugin

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
User avatar
ColeValleyGirl
Megastar
Posts: 5465
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Backup and Restore FH Settings via Windows - new plugin

Post by ColeValleyGirl »

Mark,

my use case is:
  • planning to migrate to new PC
  • backup
  • restore
If I have a major PC failure, I depend on restoring my entire system (backed up via another program) not a specific FH backup.

And so, dates are irrelevant -- all I need is backup and restore a day (or a few days later).
User avatar
BillH
Megastar
Posts: 2245
Joined: 31 May 2010 03:40
Family Historian: V7
Location: Washington State, USA

Re: Backup and Restore FH Settings via Windows - new plugin

Post by BillH »

Mark,

It is true that I only restore backups of settings occasionally, but it would be good if it could be as easy as possible.

I restore when I get a new computer, but that is very infrequent. I also restore when I've been playing around with settings to see if I like something better and then decide I want to go back to the way it was. That happens more frequently.

When I use the Backup button it creates my backups immediately. They are put into a dated subfolder. When I go to do the restore, it would be easier if I didn't even have to go into the plugin at all. If the restore .bat file was already in the dated subfolder i could just click on it and the restore is done. No having to run the plugin, select the dated subfolder, rebuild the script, and set the folder back to the parent folder.

When using the Backup button, I thought the plugin would be able to use dynamic dates for the backup script and put it in the parent folder and use hardcoded dates for the restore script and put it in the dated subfolder. Maybe that isn't the case. I don't know very much about writing plugins, I haven't written one.

I was just going for an easier user-friendly way of restoring.

I did try the method of running the plugin, selecting the dated subfolder, rebuilding the script, and setting the folder back to the parent folder. It does work, but seems a little less user friendly.

Also, after selecting the dated subfolder and going back to the main plugin window the right hand side of the window got truncated.

image1.jpg
image1.jpg (42.83 KiB) Viewed 2388 times

Thanks,
Bill
User avatar
BillH
Megastar
Posts: 2245
Joined: 31 May 2010 03:40
Family Historian: V7
Location: Washington State, USA

Re: Backup and Restore FH Settings via Windows - new plugin

Post by BillH »

Mark,

I have tried to reproduce that problem with the truncated window several times and have not been able to. Not sure what happened that one time.

Bill
User avatar
Mark1834
Megastar
Posts: 2458
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by Mark1834 »

It will be something to do with the long path description. I struggled a little getting the UI to behave elegantly for paths that could be as short as 3 characters, or over 200. What normally happens is that the window expands horizontally to the required width and rearranges the controls as necessary, but this looks like it has shrunk back down again without rearranging.

Presumably the plugin looks normal when you restart it, just a bit wider than normal? The linebreak in the text above Backup folder is hard coded, so it should take that text as its minimum width.

Picking up Helen’s point, I see the main use cases as copy/transfer to a new or replacement PC (occasional), and copying FH settings to somewhere that I backup regularly (frequent). I have relatively few apps, so only backup the full box occasionally and mostly rely on backing up the usual data folders.
Mark Draper
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Backup and Restore FH Settings via Windows - new plugin

Post by tatewise »

Mark1834 wrote: 16 Apr 2022 18:58 The simplest way is to run the plugin, select the appropriate folder, and create a fresh script. I agree that it’s slightly more complex than backing up, but I don’t think it is any more difficult than the current plugin.
I think that method is not as easy as it could be and is fraught with dangers.

Firstly, the Select button Browse For Folder dialogue does not default to the currently selected folder.
So it is a real pain to have to navigate to that backup folder before choosing the dated sub-folder.

Having chosen that sub-folder, the danger is that subsequent backups will get nested inside that dated sub-folder, which may make them difficult to find in the future.
To adjust back to the root folder via the Select button suffers the same annoyance as above.

Running FH to create the fhRestore.bat script has the risk that FH is still running when that script is run.
In that case, the Windows Registry settings will not get restored because they are silently overwritten when FH closes.
This is why I believe it is crucial for the restore to test to see if FH is running.

Like Bill, I don't see the problem with creating the fhRestore.bat when the backup script is run. It is really quite trivial.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
BillH
Megastar
Posts: 2245
Joined: 31 May 2010 03:40
Family Historian: V7
Location: Washington State, USA

Re: Backup and Restore FH Settings via Windows - new plugin

Post by BillH »

Mike,

Sorry if I am misunderstanding what you mean.

The restore .bat file is being created when the Backup button is clicked (Thanks for that change Mark). I hadn't thought about building it when the backup script is run, or is that the same thing?

The thing is that it is built without the dated subfolder in the path name in the script and it is created in the parent folder rather than in the dated subfolder.

Bill
User avatar
Mark1834
Megastar
Posts: 2458
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by Mark1834 »

Bill's interpretation is correct. Judged by what I have seen on FHUG, by far the most common use of the existing plugin is to transfer FH to a new or additional PC. Here, you would not use dated folders. If you don't, the restore script is created when the backup is run.

Personally, I think it is sufficient to warn users to not have FH open when the restore is run. I want to keep the script templates as simple as possible. If someone does forget and restore with FH running, it will be immediately apparent next time FH is run that some settings are missing. I have deliberately kept the Registry key files with their default .reg extension (unlike the existing plugin), so recovering the error is a simple matter of closing FH, locating the two key files in the backup folder, and double clicking on them.

I will look at whether folder selection can be made a little easier at the same time as I try to chase down the cause of Bill's odd resizing.
Mark Draper
User avatar
BillH
Megastar
Posts: 2245
Joined: 31 May 2010 03:40
Family Historian: V7
Location: Washington State, USA

Re: Backup and Restore FH Settings via Windows - new plugin

Post by BillH »

Mark1834 wrote: 16 Apr 2022 20:14 Presumably the plugin looks normal when you restart it, just a bit wider than normal? The linebreak in the text above Backup folder is hard coded, so it should take that text as its minimum width.

Picking up Helen’s point, I see the main use cases as copy/transfer to a new or replacement PC (occasional), and copying FH settings to somewhere that I backup regularly (frequent). I have relatively few apps, so only backup the full box occasionally and mostly rely on backing up the usual data folders.
Mark,

Sorry, I didn't see this before now. Actually the plugin looked fine after restarting it. I don't think it is even wider than normal.

I mentioned before that my use case is a bit different from Helen's or probably most other folks. I do use it just to backup the settings, make changes to the settings, see if I like the changes, and restore back to the older settings if I don't like the new ones. I know you can't tailor your plugin for just one person, so if you can't do the dated subfolder path name in the restore script and the restore script being created in the dated subfolder, I would understand. I just think it would make it easier for everyone with the common use cases as well.

Thanks,
Bill
User avatar
Mark1834
Megastar
Posts: 2458
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by Mark1834 »

I'm happy that the current plugin gives more experienced PC users all that they need, but there is a simple modification that makes restoring a backup very much easier for the general user.

I will add a Restore button to the main menu, exactly analogous to the current Backup button. This brings up a folder selection window where the user selects the backup that they wish to restore. The plugin then writes a new restore script customised for exactly that folder, and runs the script.

The first line of the script generates the message below. The user closes FH, presses any key, and the restore completes. I've tested the general principle, and it works as expected, but I'll describe the process now so folks can get their challenges in before I post yet another version.
Capture.PNG
Capture.PNG (2.85 KiB) Viewed 2333 times
For me, it ticks all the right boxes. The restore script is simple coding, and it is simple to implement in the current plugin. It may even make the plugin slightly smaller, as I can omit some of the background checking that was designed to help the general user avoid problems.
Mark Draper
User avatar
Mark1834
Megastar
Posts: 2458
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by Mark1834 »

Done! Very little extra code, and works exactly as intended. That's probably me done at the desk until this evening, so I'll strip out what is now superfluous extra verification code and test thoroughly before posting. I should end up with a version that is significantly smaller and simpler, so it is shrinking all the time as we strip out bloat that it doesn't need.
Mark Draper
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Backup and Restore FH Settings via Windows - new plugin

Post by tatewise »

Overnight I've realised there is a very simple solution to the fhRestore.bat file script such that it works for any folder.
Just dispense with the full folder path altogether, and then the script will use the current folder by default.
e.g.

Code: Select all

:: Copy this CMD Batch file into the folder holding the data to be restored.
@echo off
echo Please close FH
pause
robocopy fhProgramData "%PROGRAMDATA%\Calico Pie\Family Historian" /E /XO
robocopy fhAppData "%APPDATA%\Calico Pie\Family Historian" /E /XO
Reg import fhCURRENT_USER.reg
Reg import fhLOCAL_MACHINE.reg
That fhRestore.bat file is created by the Plugin, which never needs to be used again.

If the backup folders or files don't exist in the current folder when the script is run then nothing is restored.

To restore a dated sub-folder, the user just copies the fhRestore.bat file into the appropriate dated sub-folder and runs that batch file.

That fhRestore.bat script file even works after copying it and the backup files to another PC.

Expert users can add a cd command to change the directory if they wish to run the script from somewhere else.

Simples!!!!!
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Mark1834
Megastar
Posts: 2458
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by Mark1834 »

Good solution in the context of yesterday’s discussion, but I don’t think it is needed now.

I’ve got a much clearer mental picture now of who this plugin is aimed at. There are expert users, for whom it gives working templates that they can edit and adapt for their own use. That type of user will run the plugin only once (or even not at all once they understand the principle of what it is doing), just as they probably don’t use FH’s in-built project backups now.

The second cohort is the general user who just wants fully functional backup and restore that they can run from the familiar environment of FH. That group don’t even need to know what batch files are, and certainly shouldn’t be expected to edit them.

I think I can serve both populations with the change described earlier. I am also considering further simplifying the UI so there is just one button in each of the backup and restore frames. The “pause...” option is relabelled as “Advanced mode” and is off by default. In standard mode, the buttons run backup and restore with nothing more complicated than selecting the appropriate folder from a menu (backup in advance, as now, restore when the button is clicked). No mention at all of scripts - the user doesn’t need to know how it works. In advanced mode, the buttons generate the template scripts, similar to the current Script buttons.

With that clear distinction, it becomes much easier to design optimised solutions for each. They were getting muddled before, and probably weren’t serving either group optimally.
Mark Draper
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Backup and Restore FH Settings via Windows - new plugin

Post by tatewise »

I don't fully understand exactly what the 'second cohort general user' does to perform a restore.
It sounds like they click a button in the Plugin, which presumably runs the fhRestore.bat script.
That won't work with FH still running, so how do you get around that?
Does it rely on the echo Please close FH statement?

My proposed generic fhRestore.bat script involves no editing by such users. It is the same file for all purposes.
It does not even require copying if the fhBackup.bat script created that file in the dated sub-folders.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Mark1834
Megastar
Posts: 2458
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by Mark1834 »

I’m clear in my mind how I think it should work, so I think the best thing to do is work it through fully and update the help page to reflect the new structure. Only at that point will I post an update, so we can see it fully formed and not get distracted by discussing elements that are incomplete or taken out of context.
Mark Draper
User avatar
Mark1834
Megastar
Posts: 2458
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by Mark1834 »

Version 0.4 is attached. Although 90% of the code is unchanged, it is presented to the user in a radically different way. The modified UI doesn’t talk about scripts at all. It is a general purpose backup and restore utility that can be used by anybody without having to know anything at all about scripting, as all the details are hidden by default.
Backup and Restore Family Historian Settings via Windows.png
Backup and Restore Family Historian Settings via Windows.png (18.47 KiB) Viewed 2215 times
Select the backup location and whether you want dated subfolders, and click on Backup to run a backup.

To run a restore, select whether updated files are to be kept or overwritten, and click on Restore. Select the folder containing the backup you wish to restore. After checking the backup date and version compatibility, the plugin asks for permission to close FH in order to progress the restore. FH closes, and all restoring is carried out automatically. Reopen FH, and the settings are exactly as they were when the backup was taken.

I have confirmed that there are no objections to a Store plugin creating a script that closes FH and manages the restore, provided that it is done with explicit user consent and set up to ensure no risk of data loss.

The scripts that do all the work are created on the fly and deleted when finished with. The more experienced PC user who wants to use the scripts in their own backup process (e.g. to create either one-click or automatic backups) selects Advanced mode from the menu. Instead of running immediate backups or restores, the buttons now simply save the template scripts that implement the selected options to the nominated folder. You can extend and customise them as you wish, or just use them as they are.

I think this split gives us a much more focused plugin. Previously, it was adding complexity that advanced users didn’t need, while at the same time not being simple enough for the general user who just wants easy point and click. I’ve also corrected the issue with cropping that Bill reported, so that shouldn’t happen again.

The plugin help has been updated for the new version, so over to users to have a play…

Edit: updated file in later attachment
Last edited by Mark1834 on 23 Apr 2022 08:09, edited 2 times in total.
Mark Draper
User avatar
BillH
Megastar
Posts: 2245
Joined: 31 May 2010 03:40
Family Historian: V7
Location: Washington State, USA

Re: Backup and Restore FH Settings via Windows - new plugin

Post by BillH »

Mark,

I really like this version. I think it is very easy to understand and doesn't require any knowledge of .bat files and editing of them. I use dated subfolders. I did a test by running a backup, changing some preferences, and then running a restore using that backup from before the changes were made. All settings I changed were restored just fine.

Thanks for all the hard work.

Bill
User avatar
Mark1834
Megastar
Posts: 2458
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by Mark1834 »

Thanks for your feedback, Bill. It’s helped me focus on the things that are important for a typical user. It feels a lot more finished now, so this is probably the final draft (barring bug fixes of course). I’ll leave it on here for a couple of weeks at least to give time for any issues that may emerge.
Mark Draper
User avatar
David2416
Superstar
Posts: 398
Joined: 12 Nov 2017 16:37
Family Historian: V7
Location: Suffolk UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by David2416 »

Hi Mark,

I thought I would give this a whirl, however I am faced with this error message:
Screenshot 2022-04-23 085240.jpg
.

I have not tried any of the earlier verisons.

Thank you for your work on this.
User avatar
Mark1834
Megastar
Posts: 2458
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by Mark1834 »

:oops: Sorry David - I tidied up the code for loading the ini file in the latest version, and accidentally deleted the line that handles a missing file (i.e. first use). Every system I tested it on already had the plugin installed. It's an easy fix, so I'll post a new version shortly.
Mark Draper
User avatar
Mark1834
Megastar
Posts: 2458
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by Mark1834 »

Updated plugin attached.

[Attachment deleted as the plugin is now in the store]
Mark Draper
User avatar
David2416
Superstar
Posts: 398
Joined: 12 Nov 2017 16:37
Family Historian: V7
Location: Suffolk UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by David2416 »

Thanks Mark,

Runs very fast, will test the restore on another machine later.

Once the Command screen has opened and closed one is left with
Screenshot 2022-04-23 104150.jpg
Clicking OK gives
Screenshot 2022-04-23 104251.jpg
Is it possible to amend second image to give user reassurance of successful completion? The options help and cancel don't really provide that.
User avatar
Mark1834
Megastar
Posts: 2458
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by Mark1834 »

That's something that I played with during development. Getting the backup script to return a value indicating that all four steps were successful and having FH interpret that value to give a useful message can be a bit tricky.

By default, batch files only report the result of the last step, not an overall one. The standard plugin function for launching an external process has only very limited options for capturing that feedback. Once the process launches, it is independent of FH. That is to our advantage to give the easy restore, but works against us here, particularly now that the backup process runs so quickly.

The easy pragmatic option may be to reinstate the optional "pause output before exit" option in the store version. At the moment, it is fixed off for backup and on for restore. I've optimised the way the restore feedback is presented, so I could just keep the corresponding format for backup. That gives the user the option of a confirmation if they want it without introducing unnecessary complexity into the actual script.
Mark Draper
User avatar
David2416
Superstar
Posts: 398
Joined: 12 Nov 2017 16:37
Family Historian: V7
Location: Suffolk UK

Re: Backup and Restore FH Settings via Windows - new plugin

Post by David2416 »

Yes, understood. To me the 'cancel' on the last screenshot is the problem. What am I cancelling? 'close' would be better.

I have run the restore on my lap top and it works well.
screenshot cmd.jpg
I did notice all the plugins, census tabs and property box and source/citation settings have carried across; excellent. It is not a comprehensive test as I only use generic sources not the templated ones and I have not explored everything.

It had not maintained the default backup folder and the project location folder. Mine are all on One Drive. (That may be due to my setup in theory both machines use the same set of files as I login on the same account.)

Thank you for your work on this I really like the plugin.
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Backup and Restore FH Settings via Windows - new plugin

Post by tatewise »

Mark, the method I have used to indicate the status of a script is for it to write the status to a file.
The plugin waits until the file exists (with a failure timeout), reads that file, and deletes the file.
The file could be fhBackup.ans in the backup folder.

I think the Help forgets to say that the default backup folder and the project location folder (and other Registry items) are not restored because they are likely to be different on the target system.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
ColeValleyGirl
Megastar
Posts: 5465
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Backup and Restore FH Settings via Windows - new plugin

Post by ColeValleyGirl »

Even easier would be to use a temporary file via os.tmpname.
Post Reply