How do I recover my flows from an old SD card?

I want to recover my flows from an old SD card after it stopped booting. It is in a RPi4 and is the Bullseye version.
I have built a new card and have the old card and the file system seems to be all(?) there.
What files do I have to move from the old file system to the new file system to get my old flows back?
Thanks in advance and apologies for such a basic question
Bruce

Assuming the defaults

You want the content of the /home/pi/.node-red directory (including the hidden files that start with .)

You could just take the whole directory and it will pull in any extra nodes you may have installed.

In case you have installed a different version of nodejs you should also go into the .node-red directory and run
npm rebuild
to rebuild any nodes that need rebuilding.

Thanks both, well it NEARLY worked!

I copied the entire .node-red directory over to my new card (just in case I renamed the original .node-red-old).
I now have my flows, but in the editor is says that 4 types of node are missing. Just FYI ui_base, ui_chart, ui_gauge and ui_led.

When I go to "Manage Palette - Install" the items are greyed out as it thinks that they are already installed.

Any suggestions? I feel I am SOOO close....
Thanks
Bruce

In the .node-red folder remove and reinstall the dashboard.
npm remove node-red-dashboard
npm install node-red-dashboard
Then restart node red, clear the browser cache and reload the page. If it still doesn't work then post the node red startup log here.

OK Tried .....
npm remove node-red-dashboard
npm install node-red-dashboard

and ran node-red-log with the following output ....



10 Jan 18:37:28 - [warn] Projects disabled : editorTheme.projects.enabled=false
10 Jan 18:37:28 - [warn] Flows file name not set. Generating name using hostname.
10 Jan 18:37:28 - [info] Flows file     : /home/pi/.node-red/flows_RPi205.json
10 Jan 18:37:28 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
10 Jan 18:37:28 - [info] Waiting for missing types to be registered:
10 Jan 18:37:28 - [info]  - ui_base
10 Jan 18:37:28 - [info]  - ui_chart
10 Jan 18:37:28 - [info]  - ui_gauge
10 Jan 18:37:28 - [info]  - ui_led
10 Jan 18:37:28 - [info] Server now running at http://127.0.0.1:1880/
Stopping Node-RED graphical event wiring tool...
10 Jan 18:39:18 - [info] Stopping flows
10 Jan 18:39:18 - [info] Stopped flows
nodered.service: Succeeded.
Stopped Node-RED graphical event wiring tool.
nodered.service: Consumed 7.512s CPU time. ```

Thanks for you patience
Bruce

So I managed to remove and reinstall ui_led - from "Manage Palette" under "Nodes" it showed that ui_led was there but allowed me to disable it and uninstall it - so I could reinstall that one.

However, the other 3 nodes are all part of the "node-red-dashboard" node. That has 21 nodes and it reports that it can't find the nodes. Worse some of the nodes like ui_group are "In Use" and it won't let me stop them - so I don't get the option to uninstall them. If I could, then maybe I could reinstall the whole dashboard??

I am using the GUI through my Chrome browser now, but can I uninstall this from the command line? That way I can have node-red shut down and just delete the nodes....
Thanks
Bruce

Did you restart node red? To do that run
node-red-stop
node-red-start

Yes, restarted node-red and flushed the cache in the browser.
Even tried using Firefox instead of Chrome .....

Do you have any other ui nodes installed? If so, you should uninstall them, then uninstall the dashboard stop NR, reinstall the dashboard and then the ui nodes and restart NR.

If you don’t know and can provide your flow I can look at it and let you know.

Also I would really like to see the start of the log which you can get from
node-red-start

OK I gave up. Clearly there isn't a way to easily import flows from a "backup"!
It begs the question of how NodeRed is deployed (and backed up for recovery) in any form of production environment ?????

Anyway, I had exported my flows a few weeks ago and had the code on my disk. So I reformatted the SD card, started NodeRed, imported the Nodes that were "missing" then re-imported my flows.

I have only lost the changes that were made recently (not a big problem for me as my dashboard is fairly static) but what happens if the changes are important???

Maybe we need to suggest an improvement to NodeRed?
Regards
Bruce

Dont give up .. just explain what the problem is. I was under the impression that you had your flows back when you said

and the only problem was some missing nodes ?

if you made critical changes to your flows .. simply do a more often backup of the whole .node-red folder (on a seperate disk)

I think it's import to remember that it's possible that the reason the card stopped booting may have also corrupted content of the .node-red directory.

This is why backups should be out of band of the original storage.

Actually I am not sure that backing up the whole of the .node-red folder is the answer.

I guess what I want now is for someone who knows NodeRed really WELL (probably one of the developers) to come up with a good backup and recovery mechanism.

Going into an application and doing an "export" is not a good backup strategy. We need something that can be automated and run on a regular schedule.
Just my 2p worth
Bruce

PS My "giving up" was just to that approach. By rebuilding the card and importing my old backup I have only lost a few weeks changes and I did the rebuild during a Zoom call!!!

they did :wink: its called Projects and it synchronizes your flows with a Github repository for backup purposes. Havent used it yet personally because i just started learning Github but read a bit about the feature in the link above.

Interesting!
So that gets the flows to Github, so far so good,
How do I get them to my "normal" backup media, in my case a NAS drive?

@TotallyInformation had a backup script that runs on a schedule posted here

my knowledge on linux is very limited .. maybe you can ask how to modify it to get the backups to your NAS

1 Like

The files you need from the .node-red directory are as follows:

  • flows.json (assumes new enough build to not include the hostname in the flow file name)
  • flows_cred.json
  • settings.js
  • .config.runtime.json (assuming you have not put a credentialSecret in your settings.js)
  • .config.users.json This contains information about some editor settings
  • package.json (so you can just run npm install to add the node installed by the Palette Manager back)
  • The full content of the lib directory (assumes you have created library entries at some point)

p.s. this is basically everything in the .node-red directory minus the node_modules directory which can be regenerated from the package.json so not 100mile away from my initial statement.

2 Likes