Currently running node-RED on a local Raspberry Pi, and in the process of moving all flows etc to a Oracle VM.
In the Pi, I've been using 'Projects', but in the VM I will not be using 'Projects'.
So, I've created an archive comprising of the following files from the Pi;
Tonight I'm intending to restore these in the VM, in the .node-red/ folder.
I am already using a credentialSecret hash in my Pi's settings file, so I've added the same hash to the VM's setting file.
Does all this look correct? also, do I need to rename most of the files from for example 'flows_raspberrypi.json' to 'flows_digitalnut.json' (change the machine name)
Like all answers 'it depends'. You can start NR using node-red yourflowname so you could use node-red flows_raspberrypi.json. You could also hard code the flow file in settings.js. If you want it to connect to it automatically, then use the flows_<hostname>.json format.
Well I did exactly what was discussed above, and upon starting node-RED I got;
12 Nov 19:37:24 - [info] Server now running at https://127.0.0.1:1880/
12 Nov 19:37:24 - [warn] Error loading credentials: SyntaxError: Unexpected token in JSON at position 0
12 Nov 19:37:24 - [warn] Error loading flows: Error: Failed to decrypt credentials
12 Nov 19:37:24 - [info] Starting flows
12 Nov 19:37:24 - [info] Started flows
....and this message;
Any ideas why this has happened, and how it can be recovered please?
In your settings.js, is the value of credentialSecret the same as on the other machine?
If it was not set, then Node-RED will use a random one and print a big fat warning on start-up. I don't know where this random key is stored.
If you changed it, then just use that value. I read that you used Projects, so this key is likely in the project's subdir in the settings.json.
No errors, in fact this morning I re-copied settings.js from my original working local Pi, and have used that settings file in the VM instance (just amended https entry).
I get the same error.
As above - using a copy of the same settings file.
When "Projects" is turned off, all settings are in the settings.js (not .json).
I have never used the Projects feature, but I think the credentialSecret key is in your projects/master_flow/settings.json on the old machine.
You need to add that key to the settings.js on your new machine.
Nope, there is no settings there. The only settings (and which is also shown in the NR log) is in .node-red/settings.js
There are about 4 years worth of credentials which will be a pain to recover and re-enter.
Also, from a trust perspective, users need to have confidence that node-RED backups can be safely restored, otherwise what's the value in creating backups.
This example shows otherwise...
I just tried to move a flow and the credentials from a Pi to my Mac and I hit the same issue:
13 Nov 05:23:41 - [warn] Error loading credentials: SyntaxError: Unexpected token � in JSON at position 0
13 Nov 05:23:41 - [warn] Error loading flows: Error: Failed to decrypt credentials
in this case the original flow was NOT in a project. I then realized I had not moved the .config.json. Once I did, it worked fine.
So I would recheck the original .config.json against the one in the oracle VM to make suer they are the same
I just checked... it is indeed in the .config.json as key _credentialSecret
So once you set credentialSecret in your settings.js with your own secret, it will be removed from there at the next launch and the existing credentials will be re-encrypted with your own key.
For reference, these are the files I commit to source control. Everything to run the instance is in there. I just need to run npm install after checkout. So backups of your workspace are not really an issue if you follow that setup.
You can try to use the credentialSecret from the "Master_flow" section. That is the actual secret that was used to encrypt the credentials.
Just set it as credentialSecret in the settings.js on the new machine.
And, on the new machine, look out for the _credentialSecret in .config.json. I think it should be removed beforehand (or delete the .config.json, it will be regenerated)
I think by now it would be best to start the migration again with a fresh Node-RED workspace on the target machine. I have some steps in mind that you could follow. I can write them down, if you want.