Created
April 26, 2020 12:29
-
-
Save MorningZ/b42159b79d0b8bf473ee63f6d075821e to your computer and use it in GitHub Desktop.
Node-RED: Automatically backup flows, creds and settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
id: "4542a4c1.d485bc", | |
type: "file in", | |
z: "294e068a.106daa", | |
name: "Flows", | |
filename: "/home/username/.node-red/flows_servername.json", | |
format: "utf8", | |
x: 155, | |
y: 360, | |
wires: [ | |
[ | |
"15a6140f.7f37ac" | |
] | |
], | |
l: false | |
}, | |
{ | |
id: "955e5f11.ccfe5", | |
type: "file", | |
z: "294e068a.106daa", | |
name: "Flows", | |
filename: "", | |
appendNewline: false, | |
createDir: true, | |
overwriteFile: "true", | |
x: 310, | |
y: 360, | |
wires: [ | |
[ | |
"f0e093b.25e317" | |
] | |
] | |
}, | |
{ | |
id: "87b22caf.d5cc7", | |
type: "inject", | |
z: "294e068a.106daa", | |
name: "Save Flows", | |
topic: "", | |
payload: "restarted", | |
payloadType: "str", | |
repeat: "", | |
crontab: "", | |
once: true, | |
onceDelay: "300", | |
x: 153, | |
y: 303, | |
wires: [ | |
[ | |
"4542a4c1.d485bc" | |
] | |
] | |
}, | |
{ | |
id: "15a6140f.7f37ac", | |
type: "function", | |
z: "294e068a.106daa", | |
name: "Set filename", | |
func: " let hit = (new Date()).toISOString().match(/^(\d{4})[-](\d{1,2})[-](\d{2})[T](\d{2})[:](\d{2})/); msg.filename = "/home/username/.node-red/backups/" + hit[1] + "-" + hit[2] + "/" + hit[3] + hit[4] + hit[5] + "_flows.json"; return msg;", | |
outputs: 1, | |
noerr: 0, | |
x: 215, | |
y: 360, | |
wires: [ | |
[ | |
"955e5f11.ccfe5" | |
] | |
], | |
l: false | |
}, | |
{ | |
id: "f0e093b.25e317", | |
type: "file in", | |
z: "294e068a.106daa", | |
name: "Credentials", | |
filename: "/home/username/.node-red/flows_servername_cred.json", | |
format: "utf8", | |
x: 155, | |
y: 440, | |
wires: [ | |
[ | |
"2ac5c594.b1000a" | |
] | |
], | |
l: false | |
}, | |
{ | |
id: "ec265fed.3078b", | |
type: "file", | |
z: "294e068a.106daa", | |
name: "Creds", | |
filename: "", | |
appendNewline: false, | |
createDir: false, | |
overwriteFile: "true", | |
x: 310, | |
y: 440, | |
wires: [ | |
[ | |
"cf980872.d3df48" | |
] | |
] | |
}, | |
{ | |
id: "2ac5c594.b1000a", | |
type: "function", | |
z: "294e068a.106daa", | |
name: "Set filename", | |
func: " let hit = (new Date()).toISOString().match(/^(\d{4})[-](\d{1,2})[-](\d{2})[T](\d{2})[:](\d{2})/); msg.filename = "/home/username/.node-red/backups/" + hit[1] + "-" + hit[2] + "/" + hit[3] + hit[4] + hit[5] + "_creds.json"; return msg;", | |
outputs: 1, | |
noerr: 0, | |
x: 215, | |
y: 440, | |
wires: [ | |
[ | |
"ec265fed.3078b" | |
] | |
], | |
l: false | |
}, | |
{ | |
id: "cf980872.d3df48", | |
type: "file in", | |
z: "294e068a.106daa", | |
name: "Settings", | |
filename: "/home/username/.node-red/settings.js", | |
format: "utf8", | |
x: 155, | |
y: 520, | |
wires: [ | |
[ | |
"fa965b61.8ff288" | |
] | |
], | |
l: false | |
}, | |
{ | |
id: "85cb326f.89ee5", | |
type: "file", | |
z: "294e068a.106daa", | |
name: "Settings", | |
filename: "", | |
appendNewline: false, | |
createDir: false, | |
overwriteFile: "true", | |
x: 320, | |
y: 520, | |
wires: [ | |
[ ] | |
] | |
}, | |
{ | |
id: "fa965b61.8ff288", | |
type: "function", | |
z: "294e068a.106daa", | |
name: "Set filename", | |
func: " let hit = (new Date()).toISOString().match(/^(\d{4})[-](\d{1,2})[-](\d{2})[T](\d{2})[:](\d{2})/); msg.filename = "/home/username/.node-red/backups/" + hit[1] + "-" + hit[2] + "/" + hit[3] + hit[4] + hit[5] + "_settings.js"; return msg;", | |
outputs: 1, | |
noerr: 0, | |
x: 215, | |
y: 520, | |
wires: [ | |
[ | |
"85cb326f.89ee5" | |
] | |
], | |
l: false | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes: