Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Automatisches Backup

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Automatisches Backup

    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      Kylo Ren last edited by

      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

      4630_backup.png

      [
          {
              "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"
          }
      ]
      
      1 Reply Last reply Reply Quote 0
      • F
        friemelkarl last edited by

        Danke für den Flow!

        Funktioniert prima!

        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Support us

        ioBroker
        Community Adapters
        Donate

        738
        Online

        31.7k
        Users

        79.9k
        Topics

        1.3m
        Posts

        2
        2
        1260
        Loading More Posts
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes
        Reply
        • Reply as topic
        Log in to reply
        Community
        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
        The ioBroker Community 2014-2023
        logo