This post shows how to export your Node-RED Nodes.
This is useful if you need to:
- Backup your Node-RED flow
- Move your flow to another Raspberry Pi (or machine)
- Share your Node-RED project with others
Example
Imagine that you had the following nodes in your flow:
You would need to click the deploy button on the top-right corner to save your application.
Then you would select with your mouse all the nodes that you wish to export and they would be highlighted in orange (as shown below):
Exporting
Now with the nodes highlighted, you open the top Menu, go to Export and select Clipboard.
A new window opens. Copy the text that appears and save it.
This is how the text looks for the flow demonstrated in this example:
[{"id":"b9884d5c.5211e","type":"inject","z":"2a15e348.a7c6dc", "name":"","topic":"","payload":"hi","payloadType":"str","repeat" :"","crontab":"","once":false,"x":294,"y":123,"wires":[["cb6af 000.5a3e6"]]},{"id":"cb6af000.5a3e6","type":"debug","z":"2a15e 348.a7c6dc","name":"","active":true,"console":"false","complet e":"false","x":447,"y":123,"wires":[]}]
Importing
Now you could go to another Raspberry Pi or a machine that has Node-RED installed and you could simply import your flow.
You only have to go to the Import menu and paste your nodes in text format (as show below).
Important:Â If you have previously installed extra nodes (for example Node-RED Dashboard), you’ll also have to install those nodes in your new machine, otherwise the Import process will not work.
I want to save quite ofter as a backup, so I optimized the save process. Create a bookmarklet with this URL, and run it once every session. This creates the new button “Save to file”. Enjoy it.
Here’s the code: javascript:(function(){ $(‘#clipboard-dialog-copy’).after(‘Save to file’); $(‘#exportToFileButton’).click(function() { var uri = ‘data:text/csv;charset=utf-8,’ + escape($(‘#clipboard-export’).val()); var fileName = JSON.parse($(‘#clipboard-export’).val())[0].label; var linkField = document.createElement(“a”); linkField.href = uri; linkField.style = “visibility:hidden”; linkField.download = fileName + “.json”; document.body.appendChild(linkField); linkField.click(); document.body.removeChild(linkField); }); })();
Thanks for this.
Note that in addition to selecting with your mouse all the nodes that you wish to export, as suggested, you can hit Ctrl+A to select all.
Excellent,
as usual!!
Some of the above info I did not even find in the official node-red dokumemtation.
Please continue your (Sara&Rui) articles.
Klaus
You’re welcome! đ
I just found this but sure wish I did a year ago!! I stupidly never made any back ups when I built my “garage automation” project and my sd card got corrupted!!! I lost it all!!
I’m here again rebuilding the whole thing. It’s fun again taking the home automation course all over but lots of work! Hard to remember how I had it all set up. If I knew of saving the nodes, it would have been a breeze!
I will be saving my node red as well as making a back up of the whole card! (belt and suspenders approach)
Any tutorials here on backing up the micro SD card?? That’ s my next learning project. đ
Thank you for all the FANTASTIC tutorials!!!
Bob
Hi.
Thanks.
At the moment, we don’t have any tutorials about backing up the Rpi microSD card.
But, with a quick google search, you’ll find that information.
Regards,
Sara
The manual way: /Accessories/SD Card Copier takes copy of the current SD card that the Pi is running from and creates a bootable copy on a USB-SD adapter without interrupting the Pi.
If/when the running SD card gets corrupted, just power down and insert the copy instead and you are up and running again.