Automatic offline backups of addon data

Hello,

I’m looking for a way to store backups on users PC without user interaction AND something that could survive add-on uninstalling - or at least storage corruption. I need only few KB of space.

So far I have backups only in IndexedDB (that helps when user downgrades from Nightly channel), but I would like to offer better solution - more persistent. I have also cloud backup service, but not all users are using that.

Any ideas?

You could probably devise some bookmark based backup system, which would be in a different data silo than indexedDB/storage.local (in the future)/localStorage

1 Like

That’s a good idea for my use-case (speed-dial). Although I would like to store JSON data because my add-on has now a lot of features so user would still lost his special settings (metadata) related to those URL.

I was thinking more like some downloads API which is limited to “Downloads” folder (maybe with hidden sub-folder?).
Or something else, something that would get deleted over time - like cookies or history - history.addUrl({url: 'www.backup.bac/?30KB_of_JSON_DATA_IN_URL'}) - too much?

data:application/json, bookmark? Either way, if you think it can fit into a history entry, it should also fit into a bookmark.

I don’t think that’s possible cross-platform reliably, apart from downloads requiring a user interaction to be started.

1 Like

I suppose you could offer the “native application” option to users willing to install one. Unfortunately, it’s not an optional permission. That makes it less appealing.

https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/Working_with_files#Process_files_in_a_local_app

I don’t know if there is a dead-simple cross-platform native messaging file system interface developers can adopt. This one seems to require npm to install (maybe that is only for the developer, not the user?):

Look cool :slight_smile:

But this feature is meant for less advanced users - the kind that doesn’t think about making backups unless disaster happens…

doesn’t think about making backups unless disaster happens

That’s not thinking about making a backup, that is wishing you had made one :smiley:

I really like the bookmark Idea. Some things to consider:

  • use a descriptive title
  • escape the JSON data for use in a URL (lest you are not able to read stuff following a literal #)
    • base64 is fast and the output size is ok for JSON control chars (":,), but the build-in btoa doesn’t handle all unicode unless you re-encode the string first (atob(btoa('😄')) => :-1: )
    • encodeURIComponent is made for this, but JSON control chars and unicode will be percent-encoded, which is inefficient and ugly ":,😄 => %22%3A%2C%F0%9F%98%84
  • place a (non-localized) keyword in either title or probably better the URL for later lookup (and don’t escape it)
1 Like