Backing up node-red system

1,080 views
Skip to first unread message

Colin Law

unread,
Apr 21, 2016, 4:21:08 AM4/21/16
to node...@googlegroups.com
I am just going live with my first node-red system and following posts
here where people have run into problems I want to make sure that I
have the system well backed up so that I can get back to a working
system reasonably easily if something goes wrong. This is what I am
doing, is there anything I am missing?

1. The system is on a Pi so I occasionally take an image dump of the
SD card. This is not something that can be done routinely so it is
generally not fully up to date. It should however at least get me
back to a working system in the case of major disaster such as
corrupted SD card (which I have had happen on SD card based systems,
SD cards do not last forever).

2. The flows folder is under source control using git, with the master
on a different server, so that should be covered. I keep user defined
nodes in a subfolder of this so they are covered here also.

3. $HOME/.node-red This is backed up as it contains settings.js etc,
and locally installed nodes (though actually I don't use locally
installed nodes on the pi).

4. Globally installed nodes are in /usr/lib/node_modules (I believe)
so this is backed up. However I also see nodes in
/urs/lib/node_modules and /usr/local/lib/node_modules and not sure
what they are there for.

5. npm. I am not sure what is where with npm. I keep a note of the
version of npm installed but am not sure what I need to backup. In
particular:
I see stuff in /usr/share/npm. Is that fixed data installed with
npm or is variable configuration stored there?
The npm docs suggest there may be a global config file in /etc/npmrc
but I don't seem to have that file. Perhaps that is just because I
have not needed it.
Keeping a note of the currently installed nodes with their versions
seems like a good idea, so in my flows folder I do:
npm -g ls > npm_g_ls.txt
and put this under source control with the flows. However it would be
good to be able to just list the nodes that are actually used by the
project, along with their versions. Is this possible?

So finally, have I missed anything?

Colin

Nicholas O'Leary

unread,
Apr 21, 2016, 4:28:38 AM4/21/16
to Node-RED Mailing List
Colin,

if you look in ~/.node-red/.config.json you'll see a list of all modules that node-red has found, including location. You can use that to track what you've got installed that's relevant to node-red.

One good practice is to keep a package.json file in your ~/.node-red directory and ensure you add anything you npm install into that under the dependencies section. That way you don't have to backup the node_modules directory, you just run 'npm install' in that directory to get back what you had.

Nick


Colin

--
http://nodered.org

Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send an email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.

Dave C-J

unread,
Apr 21, 2016, 5:22:54 AM4/21/16
to node...@googlegroups.com
Re the globally installed...

when you do an npm i -g...  they will go into   /usr/lib/node_modules/...
As this is how Node-RED is installed it will itself be in /usr/lib/node_modules/node-red
and of course it drags in all it's own pre-reqs under itself at   /usr/lib/node_modules/node-red/node_modules/...

So.... the other few at the usr/lib/node_modules level are a few extras I include in the Pi image that I think are useful - but aren't in the base - like random, ping and smooth etc.

ALL of these are part of the default package and are installed and can be re-installed or upgraded using the standard sudo apt-get update && sudo apt-get install nodered    - assuming you are using the standard base install. (so to my mind shouldn't need to be backed up as a clean install would be better... but that's just me.. and of course if you've added anything else globally then they would be here also).

Re npm
currently version 2.x is still best for Pi (3 does now seem to work but takes about almost twice as long to run) - so again a   sudo npm i -g npm@2.x   should still get you the latest.

Re .node-red and package.json 
you can create this automatically if you install your extra nodes by using  npm i --save {node-name}
BUT this will pin the version to the one at install time... if you then try npm update it will only install the version in the package.json. (Which for a backup may well be a good thing). 




Colin Law

unread,
Apr 21, 2016, 6:14:56 AM4/21/16
to node...@googlegroups.com
On 21 April 2016 at 09:28, Nicholas O'Leary <nick....@gmail.com> wrote:
> Colin,
>
> if you look in ~/.node-red/.config.json you'll see a list of all modules
> that node-red has found, including location. You can use that to track what
> you've got installed that's relevant to node-red.

I have that file, but it does not appear to be complete. For example
I have installed node-red-node-pidcontrol and it is available when I
run node-red but it does not appear in ~/.node-red/.config.json

>
> One good practice is to keep a package.json file in your ~/.node-red
> directory and ensure you add anything you npm install into that under the
> dependencies section. That way you don't have to backup the node_modules
> directory, you just run 'npm install' in that directory to get back what you
> had.

Do you mean manually create and edit that file?

Colin
> To post to this group, send email to node...@googlegroups.com.

Colin Law

unread,
Apr 21, 2016, 6:17:48 AM4/21/16
to node...@googlegroups.com
On 21 April 2016 at 11:14, Colin Law <cla...@gmail.com> wrote:
> On 21 April 2016 at 09:28, Nicholas O'Leary <nick....@gmail.com> wrote:
>> ...
>> One good practice is to keep a package.json file in your ~/.node-red
>> directory and ensure you add anything you npm install into that under the
>> dependencies section. That way you don't have to backup the node_modules
>> directory, you just run 'npm install' in that directory to get back what you
>> had.
>
> Do you mean manually create and edit that file?

Ah, no, I see. npm init. Just working through that now.

Colin
Reply all
Reply to author
Forward
0 new messages