NEWS
Automatisches Backup
-
Hallo Zusammen,
ich habe einen Flow gebaut, um meine Flows automatisch zu sichern. Und zwar sichere ich die beiden wichtigen Files flows.json und flows_cred.json doppelt. Einmal per SFTP auf meinen Webspace und einmal per FTP auf meine QNAP im lokalen Netz. Mit dem timestamp-Node links kann man das Backup auch manuell starten bzw. testen.
<u>Abhängigkeiten:</u>
node-red-contrib–cron-pkjq -> Cronjob
node-red-contrib-moment -> Datum für Versionierung erzeugen
node-red-contrib-ftp-sftp -> FTP und SFTP

[ { "id": "c45a4753.b25ef8", "type": "sftp in", "z": "b03fe5a3.8e4d78", "sftp": "faa0c749.6ad568", "operation": "put", "filename": "", "localFilename": "", "fileContents": "", "fileExtension": "", "workdir": "nodered/", "savedir": "", "name": "Webserver", "x": 790, "y": 440, "wires": [ [] ] }, { "id": "f171199b.6aa1b8", "type": "comment", "z": "b03fe5a3.8e4d78", "name": "Backup", "info": "", "x": 70, "y": 400, "wires": [] }, { "id": "4096aaec.3b4664", "type": "function", "z": "b03fe5a3.8e4d78", "name": "", "func": "var temp;\nvar fileshort;\nvar path1 = \"./nodered/\"; //Webserver\nvar path2 = \"/Datensicherung/ioBroker/Node-Red/\"; //QNAP\nvar msg1 = { payload: { filedata:\"\", filename:\"\" } };\nvar msg2 = { payload: { filedata:\"\", filename:\"\" } };\n\ntemp = msg.payload;\nfileshort=msg.filename.substring(msg.filename.lastIndexOf(\"/\")+1);\n//msg.payload = {};\n//msg.payload.filedata=temp;\n\nmsg1.payload.filedata=msg.payload;\nmsg2.payload.filedata=msg.payload;\n\nmsg1.payload.filename=path1 + msg.datum + \"-\" + fileshort + \".json\";\nmsg2.payload.filename=path2 + msg.datum + \"-\" + fileshort + \".json\";\n\nreturn [msg1, msg2];", "outputs": 2, "noerr": 0, "x": 610, "y": 460, "wires": [ [ "c45a4753.b25ef8" ], [ "4b1d8412.a94f1c" ] ] }, { "id": "59b6bdd1.48f5c4", "type": "file in", "z": "b03fe5a3.8e4d78", "name": "flows.json", "filename": "/opt/iobroker/iobroker-data/node-red/flows.json", "format": "utf8", "sendError": true, "x": 420, "y": 440, "wires": [ [ "4096aaec.3b4664" ] ] }, { "id": "c92b9ba0.4dd498", "type": "inject", "z": "b03fe5a3.8e4d78", "name": "", "topic": "", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 100, "y": 440, "wires": [ [ "8acc0835.180068" ] ] }, { "id": "8acc0835.180068", "type": "moment", "z": "b03fe5a3.8e4d78", "name": "Datum", "topic": "", "input": "payload", "inputType": "msg", "inTz": "Europe/Berlin", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "YYYY-MM-DD-HHmm", "locale": "de_DE", "output": "datum", "outputType": "msg", "outTz": "Europe/Berlin", "x": 250, "y": 460, "wires": [ [ "59b6bdd1.48f5c4", "35e83be9.3dc624" ] ] }, { "id": "4b1d8412.a94f1c", "type": "ftp in", "z": "b03fe5a3.8e4d78", "ftp": "c5e360b.3513fa", "operation": "put", "filename": "", "localFilename": "", "workdir": "/Datensicherung/ioBroker/Node-Red/", "savedir": "", "name": "QNAP", "x": 770, "y": 480, "wires": [ [] ] }, { "id": "35e83be9.3dc624", "type": "file in", "z": "b03fe5a3.8e4d78", "name": "flows_cred.json", "filename": "/opt/iobroker/iobroker-data/node-red/flows_cred.json", "format": "utf8", "sendError": true, "x": 440, "y": 480, "wires": [ [ "4096aaec.3b4664" ] ] }, { "id": "f142c51f.7d4858", "type": "cron", "z": "b03fe5a3.8e4d78", "name": "Täglich", "cronExpression": "0 3 * * *", "fireAtStartup": false, "x": 70, "y": 480, "wires": [ [ "8acc0835.180068" ] ] }, { "id": "faa0c749.6ad568", "type": "sftp", "z": "", "host": "webserver.de", "port": "22", "username": "test", "password": "test", "hmac": "hmac-sha2-256,hmac-sha2-512,hmac-sha1", "cipher": "aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm" }, { "id": "c5e360b.3513fa", "type": "ftp", "z": "", "host": "qnap", "port": "", "secureOptions": "", "user": "username", "connTimeout": "", "pasvTimeout": "", "keepalive": "", "password": "xxx" } ] -
Danke für den Flow!
Funktioniert prima!
Hey! Du scheinst an dieser Unterhaltung interessiert zu sein, hast aber noch kein Konto.
Hast du es satt, bei jedem Besuch durch die gleichen Beiträge zu scrollen? Wenn du dich für ein Konto anmeldest, kommst du immer genau dorthin zurück, wo du zuvor warst, und kannst dich über neue Antworten benachrichtigen lassen (entweder per E-Mail oder Push-Benachrichtigung). Du kannst auch Lesezeichen speichern und Beiträge positiv bewerten, um anderen Community-Mitgliedern deine Wertschätzung zu zeigen.
Mit deinem Input könnte dieser Beitrag noch besser werden 💗
Registrieren Anmelden