Backup Node-Red

I accumulated about 20-30 of those early on by importing Dashboard flows from others, and not properly deleting them. It was a PITA to get rid of the excess/unused spacer nodes.

1 Like

@TechMedX can you fix the download for you backup flow as I try to import but get a jason error? Thanks

1 Like

Thanks for the heads up. I had to remember how to correctly post NR flows (need to add ass code with “```”) . It should work now. Triple click the code (windows) to highlight it all then c/p

Thanks for this. I just started using it. I have a question.

Would the delete exec node produce an error if it doent find any files older than 7 days. Mine is, but I believe I’ve set it all up correctly. The create zip file exec node is working and I’ve used the same structure.

This is the error:
Command failed: find /home/mike/Node-Red-Stuff/Complete-NodeRed-Directory-Backups/*.zip -ctime +7 -print0 | /usr/bin/xargs -0 rm
rm: missing operand
Try ‘rm --help’ for more information.

1 Like

From what they say here yes it could. Change the +7 to +0 and see how it does. Or tomorrow try a +1. LMK what you find.

Ahh thanks. I thought about changing it to 1 tomorrow, but 0 today is clever!

However, I still get the error.

Command failed: find /home/mike/Node-Red-Stuff/Complete-NodeRed-Directory-Backups/*.zip -ctime +7 -print0 | /usr/bin/xargs -0 rm
rm: missing operand
Try ‘rm --help’ for more information.

ok I think I know they issue. That code is for Mac’s version of Linux (we know they have to be different). I grabbed this code from @Royski OP.

sudo find /home/royski/sync/Backups/.zip -mtime +7 -type f -delete

Yours might be something like.

sudo zip -rq /home/mike/Node-Red-Stuff/.zip -mtime +7 -type f -delete

Sorry, I’m not great at Linux so it’s a lot of trial/error and Googling. LMK if it works, and I’ll make an edit to my OP above for RPi users.

2 Likes

Yes, thanks. You got me 99% of the way there. I’ll post the answer tomorrow for others. Sleep now.

1 Like

This was the code:

find /home/mike/Node-Red-Stuff/*.zip -mtime +7 -type f -delete

Got another minor issue with the backup to the NAS, which I’ve mostly got working. It seems to re-copy all the files from the linux machine to the NAS every time the Node Red flow runs. Does anyone know of a way to only copy the new files?

Here is the code:

cp -rf /home/mike/Node-Red-Stuff/ /mnt"/NodeRed/"

2 Likes

I been looking for a command to do that, thanks :+1:

My Google skills say

try…

cp -u /home/mike/Node-Red-Stuff/ /mnt"/NodeRed/"

Are you including that after the delete node?

EDIT: again Mac being different does not allow -u. I’m testing with -rn and seem to be working. LMK of RPi works with -u, -rn, or both.

cp -rn /Users/minimac/Backups /Volumes/1backup/Node-Red

Thanks that site was helpful. This works on linux (for those following along at home).

cp -nRu /home/mike/Node-Red-Stuff/ /mnt"/NodeRed/"

1 Like

I haven’t run through this discussion with a fine tooth comb, so sorry in advance if its been covered, but I’ve enabled the Projects feature on Node Red and its backing up all the important stuff to my Github account: Projects : Node-RED

It not only includes versioning/backup of flows but also builds up the palette dependencies so you know which to install when you restore. So far I’m been very impressed. Faffed around with the SSH keys to enable the new authentication with Github but once setup its seemless. Can be automatic or manual push to online…

It’s definitely worth a look.

2 Likes

Here is another way to backup NodeRed if you have it in Docker as well as any other Docker container you have too. How good is Docker right? :slight_smile:

2 Likes

I think I riffed on both (yours and @Royski) and leveraged the basic framework that I have for my Hubitat download/backup process! The primary difference is that I ftp the backup to a NAS and delete the local backup. I also use Pushover for notifications (have a Notification subflow that I use in various places).

If anyone wants the flow(s), just ping me.

PS: I was wondering where some of you folks went - glad to find you again :slightly_smiling_face:

4 Likes

and we’re glad you made it!

Please post the sequence. I been looking for a good way to offload the backups from my iMac. Not great w/Linux so mounting volumes, blah blah… FTP sounds like a ‘better’ approach.

1 Like

Here is the flow - let me know if you have any questions. Also, if you see any “private” information (not sure if the Pushover keys come across in the subflow), please PM me.

Flow

[{“id”:“43d0561c.bc9a8”,“type”:“group”,“z”:“934f1005.6e02”,“style”:{“stroke”:"#999999",“stroke-opacity”:“1”,“fill”:“none”,“fill-opacity”:“1”,“label”:true,“label-position”:“nw”,“color”:"#a4a4a4"},“nodes”:[“cd22e7e2.888bc8”,“8226bc6e.3f3bf”],“x”:44.33331298828125,“y”:1217.33349609375,“w”:1826.3333435058594,“h”:633.333251953125},{“id”:“cd22e7e2.888bc8”,“type”:“group”,“z”:“934f1005.6e02”,“g”:“43d0561c.bc9a8”,“style”:{“stroke”:"#999999",“stroke-opacity”:“1”,“fill”:“none”,“fill-opacity”:“1”,“label”:true,“label-position”:“nw”,“color”:"#a4a4a4"},“nodes”:[“404df91e.678728”,“4a36ae5e.fc2f6”,“e2926be.1db6c18”,“143a6921.4cb1ff”,“679f4c40.e152f4”,“e393a496.bc42a”,“8e104641.0b73f8”,“3f18280b.ffe37”,“3c8c6582.074e2a”,“1376d789.9b6be8”,“77656b03.8d502c”,“30aea08d.93dfa”,“3ad73356.874114”,“b5fc34cc.6c5b88”,“2ef6ee6d.09c662”,“7968c111.14d96”,“7fcfef26.cef7b8”,“7c29ec5d.40d38c”],“x”:75.66665649414062,“y”:1243.33349609375,“w”:1769,“h”:410.66650390625},{“id”:“34d03f0e.2cfc6”,“type”:“subflow”,“name”:“Notification Handler”,“info”:"",“category”:"",“in”:[{“x”:60,“y”:80,“wires”:[{“id”:“e450ca50.a95f18”}]}],“out”:[],“env”:[],“color”:"#DDAA99"},{“id”:“d61bf195.44c66”,“type”:“comment”,“z”:“34d03f0e.2cfc6”,“name”:“Notification Subflow”,“info”:"",“x”:130,“y”:20,“wires”:[]},{“id”:“e450ca50.a95f18”,“type”:“pushover”,“z”:“34d03f0e.2cfc6”,“name”:“Send Notification”,“device”:"",“title”:"",“priority”:0,“sound”:"",“url”:"",“url_title”:"",“html”:false,“x”:210,“y”:80,“wires”:[]},{“id”:“404df91e.678728”,“type”:“inject”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“1:15 AM Saturday”,“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:"",“crontab”:“15 01 * * 6”,“once”:false,“onceDelay”:0.1,“topic”:"",“payload”:"",“payloadType”:“date”,“x”:221.66665649414062,“y”:1350,“wires”:[[“4a36ae5e.fc2f6”]]},{“id”:“4a36ae5e.fc2f6”,“type”:“moment”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:"",“topic”:"",“input”:"",“inputType”:“msg”,“inTz”:“America/Chicago”,“adjAmount”:0,“adjType”:“days”,“adjDir”:“add”,“format”:“YYYY-MM-DD”,“locale”:“en_US”,“output”:"",“outputType”:“msg”,“outTz”:“America/Chicago”,“x”:468.6666564941406,“y”:1350,“wires”:[[“e2926be.1db6c18”]]},{“id”:“e2926be.1db6c18”,“type”:“change”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“Set File Path Parts”,“rules”:[{“t”:“set”,“p”:“filePath”,“pt”:“msg”,“to”:"/home/pi/Documents/Nodered_Backup/",“tot”:“str”},{“t”:“set”,“p”:“backupDate”,“pt”:“msg”,“to”:“payload”,“tot”:“msg”},{“t”:“set”,“p”:“fileSuffix”,“pt”:“msg”,“to”:"-Nodered_Backup.zip",“tot”:“str”},{“t”:“set”,“p”:“ftpPath”,“pt”:“msg”,“to”:"/rakesh/Home Automation Backups/Nodered Full/",“tot”:“str”},{“t”:“set”,“p”:“command”,“pt”:“msg”,“to”:“sudo zip -rq”,“tot”:“str”},{“t”:“set”,“p”:“pathToNodered”,“pt”:“msg”,“to”:"/home/pi/.node-red",“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:702.6666259765625,“y”:1350,“wires”:[[“143a6921.4cb1ff”]]},{“id”:“143a6921.4cb1ff”,“type”:“function”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“Set Full File Path”,“func”:"//Set File path+name for local backup\nmsg.localFilename = msg.filePath+msg.backupDate+msg.fileSuffix;\n\n// Set FTP path+name for backup to NAS\nmsg.ftpFilename = msg.ftpPath+msg.backupDate+msg.fileSuffix;\n\n// Command to Zip Nodered install for Exec Node\nmsg.payload = msg.command+" “+msg.localFilename+” “+msg.pathToNodered\nreturn msg;”,“outputs”:1,“noerr”:0,“initialize”:"",“finalize”:"",“x”:937.6666564941406,“y”:1350,“wires”:[[“679f4c40.e152f4”]]},{“id”:“679f4c40.e152f4”,“type”:“exec”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“command”:"",“addpay”:true,“append”:"",“useSpawn”:“false”,“timer”:"",“oldrc”:false,“name”:“Backup Nodered”,“x”:1182.6665344238281,“y”:1350,“wires”:[[“e393a496.bc42a”],[“e393a496.bc42a”],[“e393a496.bc42a”,“8e104641.0b73f8”]]},{“id”:“e393a496.bc42a”,“type”:“debug”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“Exec Output”,“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“true”,“targetType”:“full”,“statusVal”:"",“statusType”:“auto”,“x”:1444.6665344238281,“y”:1351,“wires”:[]},{“id”:“8e104641.0b73f8”,“type”:“switch”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“Zip Success?”,“property”:“payload.code”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“0”,“vt”:“str”},{“t”:“else”}],“checkall”:“false”,“repair”:false,“outputs”:2,“x”:231.66659545898438,“y”:1441,“wires”:[[“3f18280b.ffe37”],[“3c8c6582.074e2a”]]},{“id”:“3f18280b.ffe37”,“type”:“change”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“Set FTP File Paths”,“rules”:[{“t”:“set”,“p”:“filename”,“pt”:“msg”,“to”:“ftpFilename”,“tot”:“msg”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:503.66668701171875,“y”:1435,“wires”:[[“1376d789.9b6be8”]]},{“id”:“3c8c6582.074e2a”,“type”:“change”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“Zip Failed”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“Unable to zip Node-RED”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:421.6666259765625,“y”:1613,“wires”:[[“77656b03.8d502c”]]},{“id”:“1376d789.9b6be8”,“type”:“ftp in”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“ftp”:“3164f7d8.d5f6c8”,“operation”:“put”,“filename”:"",“localFilename”:"",“name”:“FTP to Backup to NAS”,“x”:738.6666564941406,“y”:1435,“wires”:[[“30aea08d.93dfa”]]},{“id”:“77656b03.8d502c”,“type”:“function”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“Set Notification Params”,“func”:"//Set error message\n\nvar message = msg.payload;\nvar topic = “Nodred backup - “+msg.backupDate;\nvar priority = 0; //values are -2,-1,0,1,2\nvar device = “”; //Blank device = All\nvar url = “”; // url to be included in message\nvar url_title = “”;// title of URL\nvar sound = “”; // notifcation sound\nvar attachmentPath = “”; //file path if attachment is included\n\n//Inputs for Notification Subflow\nmsg.payload = message;\nmsg.topic = topic;\nmsg.device = device;\nmsg.priority = priority;\nmsg.url = url;\nmsg.url_title = url_title\nmsg.attachment = attachmentPath;\nmsg.sound = sound;\n\nreturn msg;”,“outputs”:1,“noerr”:0,“initialize”:”",“finalize”:"",“x”:1466.6666564941406,“y”:1610.3336181640625,“wires”:[[“3ad73356.874114”]]},{“id”:“30aea08d.93dfa”,“type”:“switch”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“FTP Success?”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“Put operation successful.”,“vt”:“str”},{“t”:“else”}],“checkall”:“false”,“repair”:false,“outputs”:2,“x”:984.6666564941406,“y”:1435,“wires”:[[“7968c111.14d96”],[“2ef6ee6d.09c662”]]},{“id”:“3ad73356.874114”,“type”:“subflow:34d03f0e.2cfc6”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:"",“env”:[],“x”:1718.6666564941406,“y”:1611.3336181640625,“wires”:[]},{“id”:“b5fc34cc.6c5b88”,“type”:“change”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“Backup Success”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“Nodred Backup Successful”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:1242.6665954589844,“y”:1510,“wires”:[[“77656b03.8d502c”]]},{“id”:“2ef6ee6d.09c662”,“type”:“change”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“Backup Failed”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“Nodered Backup Failed”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:1177.6666564941406,“y”:1566,“wires”:[[“77656b03.8d502c”]]},{“id”:“7968c111.14d96”,“type”:“change”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“Set Local File Path”,“rules”:[{“t”:“set”,“p”:“filename”,“pt”:“msg”,“to”:“localFilename”,“tot”:“msg”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:1193.6666564941406,“y”:1429,“wires”:[[“7fcfef26.cef7b8”]]},{“id”:“7fcfef26.cef7b8”,“type”:“file”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“Delete Local Backup”,“filename”:"",“appendNewline”:true,“createDir”:false,“overwriteFile”:“delete”,“encoding”:“none”,“x”:1418.6665954589844,“y”:1429,“wires”:[[“b5fc34cc.6c5b88”]]},{“id”:“7c29ec5d.40d38c”,“type”:“comment”,“z”:“934f1005.6e02”,“g”:“cd22e7e2.888bc8”,“name”:“Backup Nodered and FTP”,“info”:"",“x”:240.33331298828125,“y”:1284.33349609375,“wires”:[]},{“id”:“3164f7d8.d5f6c8”,“type”:“ftp”,“host”:“192.168.1.110”,“port”:"",“secureOptions”:"",“user”:“rakesh”,“connTimeout”:"",“pasvTimeout”:"",“keepalive”:""},{“id”:“8226bc6e.3f3bf”,“type”:“group”,“z”:“934f1005.6e02”,“g”:“43d0561c.bc9a8”,“style”:{“stroke”:"#999999",“stroke-opacity”:“1”,“fill”:“none”,“fill-opacity”:“1”,“label”:true,“label-position”:“nw”,“color”:"#a4a4a4"},“nodes”:[“3890a76a.1c524”,“e195b311.83ac2”,“2e52854a.7120aa”,“d58d04f0.8d7948”],“x”:70.33331298828125,“y”:1689.666748046875,“w”:782,“h”:135},{“id”:“3890a76a.1c524”,“type”:“catch”,“z”:“934f1005.6e02”,“g”:“8226bc6e.3f3bf”,“name”:“Download Backup Error”,“scope”:[“404df91e.678728”,“4a36ae5e.fc2f6”,“e2926be.1db6c18”,“143a6921.4cb1ff”,“679f4c40.e152f4”,“8e104641.0b73f8”,“3c8c6582.074e2a”,“3f18280b.ffe37”,“1376d789.9b6be8”,“30aea08d.93dfa”,“7968c111.14d96”,“7fcfef26.cef7b8”,“b5fc34cc.6c5b88”,“2ef6ee6d.09c662”,“77656b03.8d502c”,“3ad73356.874114”],“uncaught”:false,“x”:206.33331298828125,“y”:1783.666748046875,“wires”:[[“e195b311.83ac2”]]},{“id”:“e195b311.83ac2”,“type”:“function”,“z”:“934f1005.6e02”,“g”:“8226bc6e.3f3bf”,“name”:“Set Error Notification Params”,“func”:"//Set error message\n\nvar message = “An error occurred at Name: “+msg.error.source.name+ “, Node Type: “+msg.error.source.type +” , Message: “+msg.error.message\nvar topic = “Nodered backup exception”\nvar priority = 0 //values are -2,-1,0,1,2\nvar device = “” //Blank device = All\nvar url = “” // url to be included in message\nvar url_title = “” // title of URL\nvar sound = “” // notifcation sound\nvar attachmentPath = “” //file path if attachment is included\n\n//Inputs for Notification Subflow\nmsg.payload = message;\nmsg.topic = topic;\nmsg.device = device;\nmsg.priority = priority;\nmsg.url = url;\nmsg.url_title = url_title\nmsg.attachment = attachmentPath;\nmsg.sound = sound;\n\nreturn msg;”,“outputs”:1,“noerr”:0,“initialize”:””,“finalize”:”",“x”:466.33331298828125,“y”:1783.666748046875,“wires”:[[“2e52854a.7120aa”]]},{“id”:“2e52854a.7120aa”,“type”:“subflow:34d03f0e.2cfc6”,“z”:“934f1005.6e02”,“g”:“8226bc6e.3f3bf”,“name”:"",“env”:[],“x”:726.3333129882812,“y”:1783.666748046875,“wires”:[]},{“id”:“d58d04f0.8d7948”,“type”:“comment”,“z”:“934f1005.6e02”,“g”:“8226bc6e.3f3bf”,“name”:“Exception Handing - Nodered Backup”,“info”:"",“x”:246.33331298828125,“y”:1730.666748046875,“wires”:[]}]

2 Likes

Bookmarked. I’ll be back to this.

1 Like

Please add three ``` (the thing next to the 1 key) to the beginning and the end of your exported flow text. That will insert the flow as code. Without them it’s not importable (see my 1st post for example as well)

“```”

flow here 

“```”

1 Like

Hope this works.

Summary
[{"id":"43d0561c.bc9a8","type":"group","z":"934f1005.6e02","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["cd22e7e2.888bc8","8226bc6e.3f3bf"],"x":44.33331298828125,"y":1217.33349609375,"w":1826.3333435058594,"h":633.333251953125},{"id":"cd22e7e2.888bc8","type":"group","z":"934f1005.6e02","g":"43d0561c.bc9a8","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["404df91e.678728","4a36ae5e.fc2f6","e2926be.1db6c18","143a6921.4cb1ff","679f4c40.e152f4","e393a496.bc42a","8e104641.0b73f8","3f18280b.ffe37","3c8c6582.074e2a","1376d789.9b6be8","77656b03.8d502c","30aea08d.93dfa","3ad73356.874114","b5fc34cc.6c5b88","2ef6ee6d.09c662","7968c111.14d96","7fcfef26.cef7b8","7c29ec5d.40d38c"],"x":75.66665649414062,"y":1243.33349609375,"w":1769,"h":410.66650390625},{"id":"34d03f0e.2cfc6","type":"subflow","name":"Notification Handler","info":"","category":"","in":[{"x":60,"y":80,"wires":[{"id":"e450ca50.a95f18"}]}],"out":[],"env":[],"color":"#DDAA99"},{"id":"d61bf195.44c66","type":"comment","z":"34d03f0e.2cfc6","name":"Notification Subflow","info":"","x":130,"y":20,"wires":[]},{"id":"e450ca50.a95f18","type":"pushover","z":"34d03f0e.2cfc6","name":"Send Notification","device":"","title":"","priority":0,"sound":"","url":"","url_title":"","html":false,"x":210,"y":80,"wires":[]},{"id":"404df91e.678728","type":"inject","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"1:15 AM Saturday","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"15 01 * * 6","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":221.66665649414062,"y":1350,"wires":[["4a36ae5e.fc2f6"]]},{"id":"4a36ae5e.fc2f6","type":"moment","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"","topic":"","input":"","inputType":"msg","inTz":"America/Chicago","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD","locale":"en_US","output":"","outputType":"msg","outTz":"America/Chicago","x":468.6666564941406,"y":1350,"wires":[["e2926be.1db6c18"]]},{"id":"e2926be.1db6c18","type":"change","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"Set File Path Parts","rules":[{"t":"set","p":"filePath","pt":"msg","to":"/home/pi/Documents/Nodered_Backup/","tot":"str"},{"t":"set","p":"backupDate","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"fileSuffix","pt":"msg","to":"-Nodered_Backup.zip","tot":"str"},{"t":"set","p":"ftpPath","pt":"msg","to":"/rakesh/Home Automation Backups/Nodered Full/","tot":"str"},{"t":"set","p":"command","pt":"msg","to":"sudo zip -rq","tot":"str"},{"t":"set","p":"pathToNodered","pt":"msg","to":"/home/pi/.node-red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":702.6666259765625,"y":1350,"wires":[["143a6921.4cb1ff"]]},{"id":"143a6921.4cb1ff","type":"function","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"Set Full File Path","func":"//Set File path+name for local backup\nmsg.localFilename = msg.filePath+msg.backupDate+msg.fileSuffix;\n\n// Set FTP path+name for backup to NAS\nmsg.ftpFilename = msg.ftpPath+msg.backupDate+msg.fileSuffix;\n\n// Command to Zip Nodered install for Exec Node\nmsg.payload = msg.command+\" \"+msg.localFilename+\" \"+msg.pathToNodered\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":937.6666564941406,"y":1350,"wires":[["679f4c40.e152f4"]]},{"id":"679f4c40.e152f4","type":"exec","z":"934f1005.6e02","g":"cd22e7e2.888bc8","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Backup Nodered","x":1182.6665344238281,"y":1350,"wires":[["e393a496.bc42a"],["e393a496.bc42a"],["e393a496.bc42a","8e104641.0b73f8"]]},{"id":"e393a496.bc42a","type":"debug","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"Exec Output","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1444.6665344238281,"y":1351,"wires":[]},{"id":"8e104641.0b73f8","type":"switch","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"Zip Success?","property":"payload.code","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":231.66659545898438,"y":1441,"wires":[["3f18280b.ffe37"],["3c8c6582.074e2a"]]},{"id":"3f18280b.ffe37","type":"change","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"Set FTP File Paths","rules":[{"t":"set","p":"filename","pt":"msg","to":"ftpFilename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":503.66668701171875,"y":1435,"wires":[["1376d789.9b6be8"]]},{"id":"3c8c6582.074e2a","type":"change","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"Zip Failed","rules":[{"t":"set","p":"payload","pt":"msg","to":"Unable to zip Node-RED","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":421.6666259765625,"y":1613,"wires":[["77656b03.8d502c"]]},{"id":"1376d789.9b6be8","type":"ftp in","z":"934f1005.6e02","g":"cd22e7e2.888bc8","ftp":"3164f7d8.d5f6c8","operation":"put","filename":"","localFilename":"","name":"FTP to Backup to NAS","x":738.6666564941406,"y":1435,"wires":[["30aea08d.93dfa"]]},{"id":"77656b03.8d502c","type":"function","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"Set Notification Params","func":"//Set error message\n\nvar message = msg.payload;\nvar topic = \"Nodred backup - \"+msg.backupDate;\nvar priority = 0; //values are -2,-1,0,1,2\nvar device = \"\"; //Blank device = All\nvar url = \"\";  // url to be included in message\nvar url_title = \"\";// title of URL\nvar sound = \"\"; // notifcation sound\nvar attachmentPath = \"\"; //file path if attachment is included\n\n//Inputs for Notification Subflow\nmsg.payload = message;\nmsg.topic = topic;\nmsg.device = device;\nmsg.priority = priority;\nmsg.url = url;\nmsg.url_title = url_title\nmsg.attachment = attachmentPath;\nmsg.sound = sound;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1466.6666564941406,"y":1610.3336181640625,"wires":[["3ad73356.874114"]]},{"id":"30aea08d.93dfa","type":"switch","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"FTP Success?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Put operation successful.","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":984.6666564941406,"y":1435,"wires":[["7968c111.14d96"],["2ef6ee6d.09c662"]]},{"id":"3ad73356.874114","type":"subflow:34d03f0e.2cfc6","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"","env":[],"x":1718.6666564941406,"y":1611.3336181640625,"wires":[]},{"id":"b5fc34cc.6c5b88","type":"change","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"Backup Success","rules":[{"t":"set","p":"payload","pt":"msg","to":"Nodred Backup Successful","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1242.6665954589844,"y":1510,"wires":[["77656b03.8d502c"]]},{"id":"2ef6ee6d.09c662","type":"change","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"Backup Failed","rules":[{"t":"set","p":"payload","pt":"msg","to":"Nodered Backup Failed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1177.6666564941406,"y":1566,"wires":[["77656b03.8d502c"]]},{"id":"7968c111.14d96","type":"change","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"Set Local File Path","rules":[{"t":"set","p":"filename","pt":"msg","to":"localFilename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1193.6666564941406,"y":1429,"wires":[["7fcfef26.cef7b8"]]},{"id":"7fcfef26.cef7b8","type":"file","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"Delete Local Backup","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"delete","encoding":"none","x":1418.6665954589844,"y":1429,"wires":[["b5fc34cc.6c5b88"]]},{"id":"7c29ec5d.40d38c","type":"comment","z":"934f1005.6e02","g":"cd22e7e2.888bc8","name":"Backup Nodered and FTP","info":"","x":240.33331298828125,"y":1284.33349609375,"wires":[]},{"id":"3164f7d8.d5f6c8","type":"ftp","host":"192.168.1.110","port":"","secureOptions":"","user":"rakesh","connTimeout":"","pasvTimeout":"","keepalive":""},{"id":"8226bc6e.3f3bf","type":"group","z":"934f1005.6e02","g":"43d0561c.bc9a8","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["3890a76a.1c524","e195b311.83ac2","2e52854a.7120aa","d58d04f0.8d7948"],"x":70.33331298828125,"y":1689.666748046875,"w":782,"h":135},{"id":"3890a76a.1c524","type":"catch","z":"934f1005.6e02","g":"8226bc6e.3f3bf","name":"Download Backup Error","scope":["404df91e.678728","4a36ae5e.fc2f6","e2926be.1db6c18","143a6921.4cb1ff","679f4c40.e152f4","8e104641.0b73f8","3c8c6582.074e2a","3f18280b.ffe37","1376d789.9b6be8","30aea08d.93dfa","7968c111.14d96","7fcfef26.cef7b8","b5fc34cc.6c5b88","2ef6ee6d.09c662","77656b03.8d502c","3ad73356.874114"],"uncaught":false,"x":206.33331298828125,"y":1783.666748046875,"wires":[["e195b311.83ac2"]]},{"id":"e195b311.83ac2","type":"function","z":"934f1005.6e02","g":"8226bc6e.3f3bf","name":"Set Error Notification Params","func":"//Set error message\n\nvar message = \"An error occurred at Name: \"+msg.error.source.name+ \", Node Type: \"+msg.error.source.type +\" , Message: \"+msg.error.message\nvar topic = \"Nodered backup exception\"\nvar priority = 0 //values are -2,-1,0,1,2\nvar device = \"\" //Blank device = All\nvar url = \"\"  // url to be included in message\nvar url_title = \"\" // title of URL\nvar sound = \"\" // notifcation sound\nvar attachmentPath = \"\" //file path if attachment is included\n\n//Inputs for Notification Subflow\nmsg.payload = message;\nmsg.topic = topic;\nmsg.device = device;\nmsg.priority = priority;\nmsg.url = url;\nmsg.url_title = url_title\nmsg.attachment = attachmentPath;\nmsg.sound = sound;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":466.33331298828125,"y":1783.666748046875,"wires":[["2e52854a.7120aa"]]},{"id":"2e52854a.7120aa","type":"subflow:34d03f0e.2cfc6","z":"934f1005.6e02","g":"8226bc6e.3f3bf","name":"","env":[],"x":726.3333129882812,"y":1783.666748046875,"wires":[]},{"id":"d58d04f0.8d7948","type":"comment","z":"934f1005.6e02","g":"8226bc6e.3f3bf","name":"Exception Handing - Nodered Backup","info":"","x":246.33331298828125,"y":1730.666748046875,"wires":[]}]
2 Likes

Perfect!

:+1:

1 Like