open-scd icon indicating copy to clipboard operation
open-scd copied to clipboard

Automatic Backup

Open OzaDay00 opened this issue 3 years ago • 7 comments

I was configuring an SCL file and web services suddenly collapsed and I lost my data since there were no back up or "go back" option. -It would be nice to have an automatic backup that forwards the file to "Downloads" directory, periodically. -Second option could be a reminder to save the files which will block all activities until user save the project.

OzaDay00 avatar Jan 20 '22 14:01 OzaDay00

Thanks for you feedback. What kind of webservices do you mean?

Sander3003 avatar Jan 20 '22 15:01 Sander3003

I actually wanted mention web location of open scd --> https://openscd.github.io/ I tried to re produce the issue, Crash happens after a bunch of configuration changes in the project.

OzaDay00 avatar Jan 20 '22 16:01 OzaDay00

@ca-d what can we do here using browser only?

JakobVogelsang avatar Jan 21 '22 17:01 JakobVogelsang

The CoMPAS version of OpenSCD supports a database backend: image However it does not support automatic backup.

Sander3003 avatar Feb 08 '22 15:02 Sander3003

I had a play recently at prototyping this using the FileSystem API (not present in all browsers). It works with Chrome (and likely Edge but probably not Safari or Firefox).

You can add this plugin as a Menu plugin using the URL: https://danyill.github.io/oscd-automatic-backup/oscd-automatic-backup.js

The plugin repo is here: https://github.com/danyill/oscd-automatic-backup

How it works is:

  • after granting permissions to a folder it will write a backup every x minutes up to a total of y backups and then remove the earliest backup.
  • some folders can't be used (which are considered "system" folders for security reasons).
  • for each session it has to be initialised by choosing a folder again (because thems the rules on the web).
  • if the user stops editing it no longer writes backups (editCount not changing).

I think for a non-database solution this is quite nice but it is only a prototype at the moment (no tests, no proper error checking etc.). I would be grateful for some comment/feedback.

danyill avatar Oct 12 '23 13:10 danyill

Thanks for your great work, Daniel! I've tried to use it for a few days and have not found anything to be broken so far. One thing that surprised me about the UI is that I could not simply click "choose folder" and get going, but instead had to click the not terribly prominently placed "enable backup" switch. To me it would be more intuitive if there was no such switch at all and instead a new "disable" button would show up between "cancel" and "choose folder" as soon as the backup is enabled.

ca-d avatar Oct 13 '23 12:10 ca-d

Thank you for these comments and your kind words, I have made some improvement, I hope you like them :wink:

I shall be pleased to receive further feedback but for my needs this is now be "feature complete".

I have also made it such that, if the user has enabled the plugin and then refreshed the page, when edits are made there is a reminder to set a directory or disable the plugin. I think that's the best we can do.

danyill avatar Oct 14 '23 14:10 danyill