This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to save my work in node-red?
#1
Hi!

I started to experiment with node-red and - it's great!
After fiddeling around with freeboard for more than a year, it just took my a few hours to create a working dashboard, where I can monitor my boat when at home.

How can I preserve (and restore ) my work in case of system crashes or updates?

best regards

Martin

   
Reply
#2
(2017-10-04, 02:38 PM)Alpenskipper Wrote: Hi!

I started to experiment with node-red and - it's great!
After fiddeling around with freeboard for more than a year, it just took my a few hours to create a working dashboard, where I can monitor my boat when at home.

How can I preserve (and restore ) my work in case of system crashes or updates?

best regards

Martin

Couple of ideas - Copy this file somewhere safe, it's all your hard work Cool 
/home/pi/.node-red/flows_openplotter.json

Also, I use evernote for anything and everything, you can highlight just one flow then use the export menu in node-red to save it  into evernote so you can find it later. Same with handy bits of function code. 

Also . here's a backup flow I use most days, you should be able to edit to suit your own machine - 
Code:
[
   {
       "id": "11ec60a3.d5763f",
       "type": "inject",
       "z": "749e8283.293f4c",
       "name": "Trigger Backups",
       "topic": "",
       "payload": "",
       "payloadType": "date",
       "repeat": "",
       "crontab": "",
       "once": false,
       "x": 140,
       "y": 1320,
       "wires": [
           [
               "198cf913.182917"
           ]
       ]
   },
   {
       "id": "198cf913.182917",
       "type": "function",
       "z": "749e8283.293f4c",
       "name": "Generate TAR commands",
       "func": "var today = new Date();\nvar day = today.getDate();\nvar month = (today.getMonth()+1);\nvar year = today.getFullYear();\n\n\nvar filestamp= day +'-' + month + '-' + year;\n\n//Node-red backup Backup\nvar returnMsg1={payload: \"-zcvf /home/pi/files/backups/noderedbackup-\" + filestamp + \".tar.gz /home/pi/.node-red/*.*\"};\n\n//opencpn  Backup\nvar returnMsg2={payload: \"-zcvf /home/pi/files/backups/OcpnBackup-\" + filestamp + \".tar.gz /home/pi/.opencpn/\"};\n\n//Openplotter Config Backup\nvar returnMsg3={payload: \"-zcvf  /home/pi/files/backups/OpenP.confBackup-\" + filestamp + \".tar.gz /home/pi/.config/openplotter/openplotter.conf\"};\n\n//kplex Backup\nvar returnMsg4={payload: \"-zcvf /home/pi/files/backups/KplexBackupDatabase-\" + filestamp +\".tar.gz /home/pi/.kplex.conf /home/pi/database\"};\n\n//Kick off the TAR commands!\nreturn [returnMsg1, returnMsg2,  returnMsg3, returnMsg4];\n",
       "outputs": "4",
       "noerr": 0,
       "x": 440,
       "y": 1320,
       "wires": [
           [
               "3d97c6a8.93359a",
               "4c801ba5.8148b4"
           ],
           [
               "3d97c6a8.93359a",
               "4c801ba5.8148b4"
           ],
           [
               "3d97c6a8.93359a",
               "4c801ba5.8148b4"
           ],
           [
               "3d97c6a8.93359a",
               "4c801ba5.8148b4"
           ]
       ]
   },
   {
       "id": "3d97c6a8.93359a",
       "type": "exec",
       "z": "749e8283.293f4c",
       "command": "sudo tar ",
       "addpay": true,
       "append": "",
       "useSpawn": "",
       "timer": "",
       "oldrc": false,
       "name": "Execute TAR commands",
       "x": 570,
       "y": 1480,
       "wires": [
           [
               "50d31cb6.bb9934"
           ],
           [
               "b3ff9b10.a33338"
           ],
           [
               "846dae36.4e4d4",
               "24cef159.e2d37e"
           ]
       ]
   },
   {
       "id": "4c801ba5.8148b4",
       "type": "debug",
       "z": "749e8283.293f4c",
       "name": "",
       "active": false,
       "console": "false",
       "complete": "false",
       "x": 720,
       "y": 1320,
       "wires": []
   },
   {
       "id": "9a7a2801.253bb8",
       "type": "ui_button",
       "z": "749e8283.293f4c",
       "name": "backup-dash",
       "group": "3034e2b3.9fa3de",
       "order": 8,
       "width": "3",
       "height": "1",
       "label": "Backup Data",
       "color": "green",
       "bgcolor": "",
       "icon": "",
       "payload": "",
       "payloadType": "date",
       "topic": "",
       "x": 170,
       "y": 1400,
       "wires": [
           [
               "198cf913.182917"
           ]
       ]
   },
   {
       "id": "50d31cb6.bb9934",
       "type": "debug",
       "z": "749e8283.293f4c",
       "name": "std out",
       "active": true,
       "console": "false",
       "complete": "payload",
       "x": 810,
       "y": 1420,
       "wires": []
   },
   {
       "id": "b3ff9b10.a33338",
       "type": "debug",
       "z": "749e8283.293f4c",
       "name": "std error",
       "active": true,
       "console": "false",
       "complete": "payload",
       "x": 820,
       "y": 1460,
       "wires": []
   },
   {
       "id": "846dae36.4e4d4",
       "type": "debug",
       "z": "749e8283.293f4c",
       "name": "return code",
       "active": true,
       "console": "false",
       "complete": "payload",
       "x": 830,
       "y": 1500,
       "wires": []
   },
   {
       "id": "24cef159.e2d37e",
       "type": "function",
       "z": "749e8283.293f4c",
       "name": "Detect Error",
       "func": "if (msg.payload==\"Error\") {\n  var returnMsg={topic: \"Error in nightly TAR backups\", payload:\"Error in nightly TAR backup operations\"};\n  return (returnMsg);\n  } else {\n      return (null);\n  }\n  \nreturn msg;",
       "outputs": 1,
       "noerr": 0,
       "x": 570,
       "y": 1540,
       "wires": [
           [
               "64c49827.820e88"
           ]
       ]
   },
   {
       "id": "64c49827.820e88",
       "type": "debug",
       "z": "749e8283.293f4c",
       "name": "",
       "active": true,
       "console": "false",
       "complete": "false",
       "x": 830,
       "y": 1540,
       "wires": []
   },
   {
       "id": "28470f9d.1be51",
       "type": "comment",
       "z": "749e8283.293f4c",
       "name": "Saves backups as TAR.GZ",
       "info": "Trigger kicks off the flow at 0200 every morning.\n\ntar commands are built, less the actual \"tar \" at the beginning\n(note the space!) because the exec command node requires a\ncommand to be entered to it, it can't just accept everything\nfrom the incoming message.\n\nThe system is designed to make one backup each day of the week,\nso inserts three letter day names into the output filename.\n\nOutput files are sent to /backups. You can then copy these off\nthe node-red system with whatever means you chose. I use samba.\n\nMultiple tar commands can be issued in parallel by configuring\nmultiple outputs from the function which creates the commands.\n\nThis example makes four tar.gz files:\n\nRoot ID (this is where I keep loads of stuff, bad practice, I know!)\nApache html files (/var/www)\nNode-Modules (/usr/lib/node_modules)\nNode Red Settings (which I have configured to /var/node-red)\n\nNB: The exec command \"tar \" must have a trailing space!\n\nEmails are sent to alert of error, if any of the commands issued\nreturn the string \"Error\".\n",
       "x": 130,
       "y": 1260,
       "wires": []
   },
   {
       "id": "3034e2b3.9fa3de",
       "type": "ui_group",
       "z": "",
       "name": "Shutdown",
       "tab": "de6fba2.670c748",
       "disp": true,
       "width": "6"
   },
   {
       "id": "de6fba2.670c748",
       "type": "ui_tab",
       "z": "",
       "name": "Gauges",
       "icon": "dashboard",
       "order": 1
   }
]

Node-red must be one of the most useful pieces of free software there is Cool
Reply
#3
i highlight my flows and export to clipboard and then paste and save them to text editor on a usb drive or google drive.
jim
Reply
#4
Thank you! Just finished the simple version of the backup via copy.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)