Backup & migrate

Good day,

I am currently running a node-red installation for 3 years on a raspberry-pi.
i have installed and removed multiple applications (not related to node-red) on this system so it was time to start fresh.
I installed a fresh new pi (same hardware). with all the software needed. after the test i will swap the sd-cards.
However i found somewhere that the best way to move node-red was make a backup of /root/.node-red and restore this.
this isn't working.
After starting node-red there are some errors. and the webpage is empty.(as in a new installation)


Welcome to Node-RED
===================

30 Aug 16:45:51 - [info] Node-RED version: v1.0.6
30 Aug 16:45:51 - [info] Node.js  version: v10.21.0
30 Aug 16:45:51 - [info] Linux 4.19.97-v7+ arm LE
30 Aug 16:45:58 - [info] Loading palette nodes
30 Aug 16:46:16 - [info] Dashboard version 2.9.8 started at /ui
30 Aug 16:46:19 - [warn] ------------------------------------------------------
30 Aug 16:46:19 - [warn] [node-red-node-serialport/serialport] Error: The module '/root/.node-red/node_modules/serialport/build/Release/serialport.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
30 Aug 16:46:19 - [warn] ------------------------------------------------------
30 Aug 16:46:19 - [warn] Missing node modules:
30 Aug 16:46:19 - [warn]  - node-red-node-email (0.1.29): e-mail, e-mail in
30 Aug 16:46:19 - [warn]  - node-red-node-feedparser (0.1.12): feedparse
30 Aug 16:46:19 - [warn]  - node-red-node-twitter (1.1.2): twitter-credentials, twitter in, twitter out
30 Aug 16:46:19 - [info] Removing modules from config
30 Aug 16:46:19 - [info] Settings file  : /root/.node-red/settings.js
30 Aug 16:46:19 - [info] Context store  : 'default' [module=memory]
30 Aug 16:46:19 - [info] User directory : /root/.node-red
30 Aug 16:46:19 - [warn] Projects disabled : editorTheme.projects.enabled=false
30 Aug 16:46:19 - [info] Flows file     : /root/.node-red/flows_raspberrypi.json
30 Aug 16:46:19 - [info] Creating new flow file
30 Aug 16:46:19 - [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.
---------------------------------------------------------------------

30 Aug 16:46:19 - [info] Starting flows
30 Aug 16:46:19 - [info] Started flows
30 Aug 16:46:19 - [info] Server now running at http://127.0.0.1:1880/

Another way of migrating that i found is export all to clipboard and import.
but then the addons are still missing. (yes i can manualy check all the plugins and install them.... but what is the use of an backup when its not complete?)

the old system is still running.
i have the original /root/.node-red folder saved.

What is the correct way to backup & migrate?

Thanks
Mark

Normally your flows would not be in root, they would be in your user folder, by default the user pi. Have you installed using the script from the node red guide for installing on a pi?

To answer the question of the missing nodes, then you should not restore the .node-red/node_modules folder but should make sure that package.json has been restored, then, in the .node-red folder run npm install which will install them. It is necessary to reinstall them as you might have different version of nodejs and even different processor architecture.

between the old version you had and the latest some nodes were removed from core install - so you may need to re-add them manually - they are all (4) listed in that debug you posted - so should be easy to re-add.

Thank you for the answer.
today i finaly found time to continue the project.

The installation was simply by apt-get install node-red
this way the system install it as root.
I know that it isn't the best option. but the raspberry is running only node-red (en mosquitto) so for me it isn't a problem.

i moved the backup folder to .node-red.copy
restored the original .node-red folder
copyed the packages.json
get an message that i need to "upgrade" my node.js....
and get an error about a folder creation.
manualy created the folder and tried again. however exactly the same error.

root@raspberrypi:~# cp .node-red.copy/package.json .node-red/package.json
root@raspberrypi:~# cd .node-red
root@raspberrypi:~/.node-red# npm install

npm WARN npm npm does not support Node.js v10.21.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
npm WARN notice [SECURITY] axios has the following vulnerability: 1 moderate. Go here for more details: GitHub Advisory Database · GitHub. 5.4 - Run npm i npm@latest -g to upgrade your npm version, and then npm audit to get more info.

node-dht-sensor@0.4.3 install /root/.node-red/node_modules/node-dht-sensor
node-gyp configure

gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/root/.node-red/node_mod ules/node-dht-sensor/build'
gyp ERR! System Linux 4.19.97-v7+
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "configure"
gyp ERR! cwd /root/.node-red/node_modules/node-dht-sensor
gyp ERR! node -v v10.21.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN ws@7.3.1 requires a peer of bufferutil@^4.0.1 but none is installed. Yo u must install peer dependencies yourself.
npm WARN ws@7.3.1 requires a peer of utf-8-validate@^5.0.2 but none is installed . You must install peer dependencies yourself.
npm WARN node-red-project@0.0.1 No repository field.
npm WARN node-red-project@0.0.1 No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-dht-sensor@0.4.3 install: node-gyp configure
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-dht-sensor@0.4.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional log ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-09-10T18_42_39_613Z-debug.log
`

apt-get install is not the recommended way for installing on the Pi. You will end up with old versions of both Node and npm, leading to errors when you try to install some nodes - such as exactly what you have hit.

Use the install script we provide for the Pi - https://nodered.org/docs/getting-started/raspberrypi

@koos147 you don't need to start again, you should just be able to run the script in link Nick provided and it will sort it out.

Thanks. finaly succeed with the installation.

Strange that there is an package availible that is to old to use.
i have removed the apt-get version. went back to the pi user. and installed node-red as pi user.
restored package.json and run npm install
got verry strange errors about the node-serialport
opened the package.json and removed the line. after this the npm install worked fine.

restored the flow file. but that didn;t work
removed the file... opened the file and imported it from clipboard.
after this installed the serialport and everything works now.

so conslussion is that a backup from the .node-red folder is usefull but its not that simple to restore.

I have done this on numerous times without issue, but that was starting with a known working system. In your case, I think, you started with a broken system having problems with serialport. I think it very likely that the problems you had with npm install were a hangover from the previous issues.

OS repositories normally lag behind the latest versions of everything. With essentially stable software, such as LibreOffice for example, being a few months behind is not an issue. With something undergoing rapid development like node-red then even a few months can be a big deal.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.