However if you feel that it is a problem, how about publishing the script so that the wider node-red community could benefit if they feel that have the need?
--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Got one sitting opposite me waiting for me to get one of those PC type plugs to go in the back J
--
http://nodered.org
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/U9FSjFuREeU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
Paul, we you aware we already create backups of these files whenever you hit deploy?
Nick
No need to save face… it is great that Node-Red does a backup whenever you deploy – of course you could deploy the wrong thing twice and mess up – hence all is not lost… if you modified your script to do SEQUENTIALLY NUMBERED backups, then it would still have a use for saving SNAPSHOTS of the state of things – rather handy for experimenting with various stuff in Node-Red – which is what I am doing right now.. You up for that Zenofmud?
I’m going to try this and THANK YOU for the effort - I’m aware of that section of the file as I’ve added “moment” in there so I can use moment…
Seems to me that a human readable date might be more useful than a timestamp (“oh, yes, messed that up this morning – lets go back to last night’s version”).
Tested, works a treat!
Erm… no. I checked to see where you were getting the time from – and I see it is from startup…
You’re assuming (forgive me if I’m wrong) that DEPLOY is always used in full… I never use it in full – I have so much stuff (which is why I’m keen on backups) that it would take an age. I use partial deploy – only nodes that have changed – and this does not get triggered. Good idea though J
Yes, well spotted Nicholas – use the watch node to watch for the Node-Red automatic flow backup – right – I’m onto it.
Ok, here it is.. this works on any Deploy – even partial ones – and puts in a usable date and time.
Thanks guys – another useful tool.
Pete.
[{"id":"9a71729d.658e9","type":"watch","z":"55620bb2.aa9df4","name":"Watch Node-Red flow files","files":"/home/pi/.node-red","x":130,"y":510,"wires":[["bf412c5b.40bed"]]},{"id":"d822a643.27dd58","type":"function","z":"55620bb2.aa9df4","name":"Build filenames","func":"// You need to have edited your settings.js file and uncommented the line\n// // os:require('os'),\n// in the 'functionGlobalContext: {'' section\ncontext.global.curtime = msg.payload;\nvar hostname = context.global.os.hostname();\nvar homedir = context.global.os.homedir();\nvar flow_path = homedir + '/.node-red/';\nvar flowfile = flow_path + 'flows_' + hostname +'.json';\nvar credfile = flow_path + 'flows_' + hostname +'_cred.json';\ncontext.global.bkupflowfile = flow_path + 'flows_' + hostname +'_'+ context.global.curtime+ '.bkup';\ncontext.global.bkupcredfile = flow_path + 'flows_' + hostname +'_cred_'+ context.global.curtime+ '.bkup';\n\nvar msg1 ={ filename: flowfile };\nvar msg2 ={ filename: credfile };\nreturn [msg1, msg2];\n","outputs":"2","noerr":0,"x":158,"y":607,"wires":[["5e044d22.a1fbb4"],["5e044d22.a1fbb4"]]},{"id":"5e044d22.a1fbb4","type":"file in","z":"55620bb2.aa9df4","name":"read flows","filename":"","format":"utf8","x":333,"y":607,"wires":[["3fa1589f.c05ea8"]]},{"id":"b92e20bc.46d1e","type":"file","z":"55620bb2.aa9df4","name":"backup flows","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"true","x":396,"y":663,"wires":[]},{"id":"3fa1589f.c05ea8","type":"function","z":"55620bb2.aa9df4","name":"choose backup file name","func":"// test the file name to see if it is the flow or credentials file and use the appropriate one\nif (msg.filename.search(\"cred\") > 0) {\n msg.filename = context.global.bkupcredfile;\n} else {\n msg.filename = context.global.bkupflowfile;\n}\nreturn msg;","outputs":1,"noerr":0,"x":187,"y":663,"wires":[["b92e20bc.46d1e"]]},{"id":"9020dbae.6fdf28","type":"comment","z":"55620bb2.aa9df4","name":"Automatic backup of flow/credential files with a timestamp each time you DEPLOY","info":"This flow will backup your flow and credential json files each time you press 'Deploy'. \nNOTE: it will only work if you are using the defaults for the name of the file containing the flows.\n\nYou must edit your 'settings.js' file and find the section:\n\n functionGlobalContext: {\n // os:require('os'),\n // bonescript:require('bonescript'),\n // jfive:require(\"johnny-five\"),\n // j5board:require(\"johnny-five\").Board({repl:false})\n\nand uncomment the 'os:require('os'), line so you have:\n\n functionGlobalContext: {\n os:require('os'),\n // bonescript:require('bonescript'),\n // jfive:require(\"johnny-five\"),\n // j5board:require(\"johnny-five\").Board({repl:false})\n\nthis will allow this flow to grab the file paths to make the backups.","x":303,"y":465,"wires":[]},{"id":"bf412c5b.40bed","type":"function","z":"55620bb2.aa9df4","name":"Check for json file change - insert time string","func":"\nif (msg.payload.indexOf(\".json\") > -1) \n { msg.payload=new Date().toISOString().replace(/\\..+/, ''); \n return msg;\n }","outputs":1,"noerr":0,"x":252,"y":560,"wires":[["d822a643.27dd58"]]}]
From: node...@googlegroups.com [mailto:node...@googlegroups.com] On Behalf Of Nicholas O'Leary
Sent: 06 January 2016 20:58
Shame we don’t have the input equivalent of the DEBUG on/off button (sending 1 or 0) – could have a PAUSE facility on this!!
What... Pause on the backups ? You then know exactly when it will crash .... About an hour after you hit pause and do a load of changes :-)
Haaaaah
On 6 January 2016 21:30:30 Dave C-J <dce...@gmail.com> wrote:
What... Pause on the backups ? You then know exactly when it will crash .... About an hour after you hit pause and do a load of changes :-)
--
My friend Google helped me :-)
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/93466348-75a2-4de6-9cf2-e571f697e01d%40googlegroups.com.
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/8b7d2770-f683-4388-b64d-3f334f72a493%40googlegroups.com.
Imagine: click deploy, file gets written, watch node generates message, node red stops flow, message get discarded before it gets to file node. I suspect your approach will not work.Colin
On 17 Jul 2017 7:48 a.m., "Bobo" <bulloc...@gmail.com> wrote:
But now I shall contradict my previous observation by saying that I just had an occurrence where the correct filename was displayed from the watch node after a deploy. But the backup files were not produced in this instance. So there may be two separate issues.--
On Monday, 17 July 2017 00:38:14 UTC+8, Bobo wrote:My previous reply was a bit ambiguous. I meant to say that when I put a debug node on the change node, there is no output being generated.
On Monday, 17 July 2017 00:34:44 UTC+8, Bobo wrote:Yes, the problem does indeed seem to be with the watch node. Nothing gets generated when it does not work.
On Sunday, 16 July 2017 21:51:07 UTC+8, Colin Law wrote:I would be surprised if taking the spaces out fixed an intermittent issue.
Have you put a debug on the change node so you can see if it is that
which is failing? If it isn't that then put debugs at each point and
see where it gets lost.
Colin
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.