Help with backup location of flows

Hi all,

I'm a complete noob with Node Red, so please go easy - I have Node Red running on a RasPi 3.

I had a few flows on my Node Red when I decided to upgrade.
Unfortunately the upgrade "hung" and I had to restart it. When I eventually got Node Red upgraded, all may flows were gone. It gave me some error, but I can't remember what it was... :man_facepalming:t3:

Is there anywhere that I can look to see of there is a backup on the RasPi? The only node I really need (although having all the flows back would be awesome) is a function Node that I cannot for the life of me remember how I "programmed" - it took sensor readings from a Sonoff POW R2, Status8 command and sent it to a InfluxDB node. But I can't get it working, hence needing the backup...

Any help would be really awesome.
Thanks in advance everyone :grin:

With a standard install, your flows are in ~/.node-red.

Like the OP all my flows, which I spent countless hours on, are gone. Stupidly I did not make a backup of any file in the ~/.node-red directory. I'll figure out a way to do this automatically, either locally or over the network, e.g. to github. If you don't make backups, consider it. Do not assume that nodejs, node-red are stable enough to not have it hit you. The alternative will be inevitably very painful and time consuming.

Thanks @TotallyInformation, appreciate the reply.
I found the flows.json file. Will this have all the old flows or only the current flows in my Node-Red?

If this will only have the current flows, is there anywhere I can try looking for older flows that may be "backed up" somewhere?

The issue is not node-red nor is it node - the issue is universal. If you don't do a backup, expect to get burned.

How did you lose flows? HDD failure? SD card failure? Mis-operation? Install rouge node?

The flows file only contains your current flows.

Node-RED keeps one level of backup whenever you press the Deploy button - you'll find a file called .flows.json.backup alongside your flows.json file.

Note you need to also backup the flows_cred.json file - as that contains any credentials used by your flow.

Damn, so I'm fresh out of luck then...
Oh well, guess this is as good a time as any to build my flows from the ground up again..

Thanks for all your help everyone

Are there any other files in the .node-red folder that you don't know what they are?

I was installing zigbee2mqtt on the same machine as node-red and the logs said there was an error with the version of node, it did not support 10.* so I tried to downgrade my node install which didn't work. I decided to install node afresh using the script

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

which doesn't remove the flows. Apart from that I can't tell what could have removed them, certainly my bash history shows that I didn't explicitly remove them.

The bottom line is I was kicking myself for not making regular backups. The git integration in 1.2 sounds perfect for my needs. node-red in operation has always been rock solid for me, its just the nodes/flow file integrity hasn't been reliable (this is the second time I've burnt myself! :frowning: ) and that may well be node, not node-red, I just don't know at this stage. It was a shock when I realised that all my carefully curated flows were gone forever.

what operating system is this?

Mac has time machine, window has "previous versions" (unsure about linux)

Have you searched your entire computer? (PS, windows search is just terrible - dont bother)

On windows, I use a program called "agent ransack" to search whole computer for any file named *.json and to search inside that file for something I remember from my flow

image

Raspbian GNU/Linux 10 (buster)

For anyone in a similar situation, I now use a simple alias command to manually and crudely backup my nodes (this went into ~/.bashrc)

alias backup_node_red='tar zcvf ~/node-red-$(date +%Y%m%d).tgz --exclude "node_modules" --exclude "lib" ~/.node-red'

I posted a backup script a short while ago:

Node-RED Backup script (BASH & RSYNC) - Share Your Projects - Node-RED Forum.

It keeps 7 daily and 12 monthly backups as written but would be easily amended.