Restore individual tab (flow) in Node-Red Add-On

Hypothetical question, how would I go about restoring an individual tab (I think it’s called a flow ?) in the Node-Red add-on ? I’m envisioning a situation where I make an inadvertent mistake with a tab, and want to examine a previous version of it.

Seems like I would:

  • Grab a copy of most-recent snapshot
  • Expand the tar file in a temp directory somewhere
  • Find the /config/node-read/flows.json file

That’s where I get stuck. Seems like flows.json is a very long single-line of JSON, so editing that, and finding the individual flow that I want to import is challenging.

1 Like

The easiest solution that comes into my mind is to:

  1. take another snapshot of NR
  2. revert the old snapshot
  3. export the deleted flow as JSON
  4. revert to the new snapshot
  5. import the exported JSON

But it’s only hypothetical, so no worries

I made a little progress here. I downloaded my current flows.json, opened it in VS Code, and formatted the document. Went from 1 line to 6700 lines, and much easier to read. Appears to be a fairly flat structure. Feels like the top section maps the “tab name” to an “id”. Then there’s just a very long list of individual nodes. Perhaps I just grab all the nodes matching the id from the tab I desire ?

Maybe I should export one of my tabs to see the ideal format of the file I’m trying to artificially construct from the larger flows.json

Modifying this file could work, but it also couldn’t. What speaks against reverting a snapshot?

Thanks for the reply. I guess given the growing complexity of my setup, the idea of reverting the entire Home Assistant config to see a previous version of one of my node-red flows feels a bit… too big. But I suppose the idea of reverting my test instance using my production snapshot might be worth considering.

Anyway, just wanted a second opinion on options for accessing individual flows from previous backups. Seems like I haven’t overlooked anything obvious, so thanks for chiming in on that. I suppose another option is a periodic manual export from Node-Red, but always prefer options that don’t rely on me remembering to do something :slight_smile:

You could only revert the NR part of your snapshot (not your entire HA setup) or try to swap out the entire flows.json files instead of copying parts of it

1 Like
  1. I didn’t know you could revert part of a snapshot, I’ll read about that.
  2. Replacing just the flows.json file (temporarily) is a great idea, didn’t think of that !

Thanks again, love this Community !

-Chad