Backup Node-Red

A lot of this is borrowed from @Royski posts on ‘that other site’. I made some modifications and will post my version of it below.

First THANK YOU!! @Royski this just saved my week! I recently got a message in NR saying that changes were made outside the page I was on. It said there were no conflicts so just merge them. When the page reloaded ALL my Flows were gone. :scream: All I had was a single blank Flow. :cold_sweat:

After I picked my chin up off my desk I remembered my backups. With-in 10 minutes I had everything thing back. :triumph:

If you do not have a backup routine for NR do it now!

Title - Backup Node Red

Summary
Pretty straight froward this creates a backup zip of your .node-red directory, and retains a given number of them. I use a minimac, so these commands are geared toward that deployment. You can edit the backup .node-red, and deleted older than, nodes according to your setup.

My plans is to have these zip files then stored on another machine, but I’m still working those commends out.

Sequence
[{"id":"55b429b6.23dd98","type":"exec","z":"102546f5.2a0b69","command":"zip -rq /Users/minimac/Backups/node-red-backup-$(date +%Y-%m-%d).zip /Users/minimac/.node-red","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"backup .node-red","x":410,"y":880,"wires":[[],[],["d64a5bd4.0cd4c8"]]},{"id":"83228b65.b859a8","type":"inject","z":"102546f5.2a0b69","name":"daily @2200","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 22 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":880,"wires":[["55b429b6.23dd98"]]},{"id":"bc9940d4.62799","type":"debug","z":"102546f5.2a0b69","name":"backup-log","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1250,"y":960,"wires":[]},{"id":"d64a5bd4.0cd4c8","type":"switch","z":"102546f5.2a0b69","name":"check success","property":"payload.code","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":600,"y":900,"wires":[["fada7520.17dc78"],["bc9940d4.62799","2b64fef9.8cd882"]]},{"id":"fada7520.17dc78","type":"exec","z":"102546f5.2a0b69","command":"find /Users/minimac/Backups *.zip -ctime +7 -print0 | /usr/bin/xargs -0 rm","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"delete older than 7 days","x":710,"y":840,"wires":[[],[],["e2a2439c.8253f"]]},{"id":"e2a2439c.8253f","type":"switch","z":"102546f5.2a0b69","name":"check success","property":"payload.code","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":900,"y":900,"wires":[["54c47c9a.23c7c4"],["bc9940d4.62799","2b64fef9.8cd882"]]},{"id":"54c47c9a.23c7c4","type":"template","z":"102546f5.2a0b69","name":"success msg","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":" NR Backup compelete.","output":"str","x":1070,"y":860,"wires":[["bc9940d4.62799","ad48a65f.464328"]]},{"id":"91d29e4f.d8223","type":"comment","z":"102546f5.2a0b69","name":"Daily Backups","info":"__","x":150,"y":820,"wires":[]},{"id":"fe6d17d1.659898","type":"switch","z":"102546f5.2a0b69","name":"check success","property":"payload.code","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1160,"y":720,"wires":[[],[]]},{"id":"a955dc5c.617ca","type":"link out","z":"102546f5.2a0b69","name":"NR BAckup Failed Request Input","links":["f045d7ed.ebeea8"],"x":1075,"y":1000,"wires":[]},{"id":"2b64fef9.8cd882","type":"change","z":"102546f5.2a0b69","name":"NR Backup Failed","rules":[{"t":"set","p":"payload","pt":"msg","to":"NR Backup Failed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":1000,"wires":[["a955dc5c.617ca"]]},{"id":"ad48a65f.464328","type":"link out","z":"102546f5.2a0b69","name":"Backup Success","links":["f045d7ed.ebeea8"],"x":1215,"y":840,"wires":[]},{"id":"d92e72be.2ba3d","type":"exec","z":"102546f5.2a0b69","command":"cp -rf /Users/minimac/.node-red /Volumes\"/Personal/~HE Stuff/node-red/Backups/\"","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"copy file to NAS","x":980,"y":780,"wires":[[],[],["fe6d17d1.659898"]]}]

The backup is scheduled, but can be changed in the first node, and executes here at 22:00 every day.

4 Likes

Alternatively, I use a local Subversion repository to keep my site-specific stuff in. Both have there merits and there’s no harm in doing both…for the OCD among us. :wink:

1 Like

I found that the entire .Nodered folder is huge and I just copy the 10-12 important files. That number went up with most recent update of Node Red. Then I FTP them from RPi to a desktop. If i get a crash/disaster, then all of the flows are saved but I do have to reinstall all of the pallets. I’ve had to do it once already and took 15-20 minutes. No big deal because NR tells you what is missing. I do feel safer now that my RPi is booting and running off an SSD instead of SD.

1 Like

Indeed.

I should have mentioned which ones I version:

  • flows_pvr.json
  • flows_pvr_cred.json
  • package-lock.json
  • package.json
  • settings.js

My NR isn’t very complex so these files are sufficient, even with the recent split of .config files.

I also do a complete system backup weekly.

1 Like

Yeah good call I have been backing mine up for a while now as well. I created this one which works well but as you know there is a million ways to do things in NodeRed :stuck_out_tongue:

EDIT: updated to include my new backup flow for NodeRed in Docker.

2 Likes

I wouldn’t exactly call 30Mb huge (unless your on a tiny SD lol) , but yes you don’t need the entire folder. Unless you’re an over protect IT admin. In which case your backups, have backups of their offsite backups.

and with backups redundancy is a GOOD thing! Hopefully everyone has picked at least 1 or 2 :wink:

2 Likes

Then is this a problem…
image

FWIW, my node-red directory tree is about 150 megabytes. A tarred, gzipped backup is 30 megabytes.

I use a shell script that makes one every morning and prunes the backup drive to retain 2 weeks worth of backups.

Edit:
I also make a weekly “dd” backup of the entire eMMC on my Odroid N2 as a gzipped file. That backup file is 6.2 gigabytes, and I retain those for 2 months.

1 Like

Darn, my Node Red browser GUI is painstakingly slow and I thought if my folder size was unusually large, that could be related.

It’s really weird. If I were to delete a sequence with 10-15 nodes, it could take up to a minute for the nodes to disappear. Even deleting 1-2 nodes takes more than a second. I’ve moved my flows to different RPis and tried using different computers’ browsers and still the same.

I posted on Node Red community and a few people tried to help but no luck. We found some scripts that were taking all of that time to run but I am ignorant and don’t know how to continue to troubleshoot. I am just hoping it doesn’t continue to get worse.

It seems to have started about time of the major Node Red update where groups were added but I don’t use Groups.

I have noticed no slowdown in speed of device initialization, flow performance, or flow deployment fortunately.

FWIW, I had no problem when groups were added, although I’m not impressed with the way the lone group I have works and I’ll remove it when I remember to. :roll_eyes:

I did read some posts on the NR community about groups being buggy upon release but I don’t think there was any mention of what you’re seeing. In fact, I don’t recall seeing your kind of terrible response with any NR setup.

I wish I could help but I can say … good luck.

I have seen slow downs in my NR too, sometimes up to a minute or more (sometimes I just move on and come back). Groups are the worst. If I have to edit a group I un-group, edit, re-group. I run NR on a headless SSD iMac with nothing else running, so it has ample power. :man_shrugging:

@stephenn, @TechMedX, which NR version are you running? I’m on v1.2.2 and staying there until there’s a 1.2.6 or later that’s good out of the box.

1 Like

1.1.3 Guess I should update

1 Like

1.2.2.

I am running on a RPi 4 8Gb RAM/128 Gb SSD.

2 Likes

There is now. I’ve been running it for a few hours. Seems ok.

2 Likes

:rofl:
Why so patient?
:rofl:

2 Likes

My hardware is very similar to yours. Hexacore 64-bit SBC, 4 GB RAM, 32 GB eMMC, 160 GB SSD. It is really fast while editing flows. So your install should be equivalently speedy.

I appreciate the notification but I’ll wait a couple days before nudging the package maintainer on Arch Linux to update his package. Wait… um… how can I rephrase that…

2 Likes

:rofl: :rofl:

1 Like

It turns out I somehow accumulated over 1100 dashboard spacer nodes that only show in the Configuration Window that were causing havoc. I eventually had to open my Flows.json for with a text editor and delete them all and that worked. Very bizarre and I have no idea how I screwed that up.

1 Like