[98_backupToStorage] Modul zum upload des FHEM Backups auf ein Storage

Begonnen von CoolTux, 18 Juni 2020, 13:14:42

Vorheriges Thema - Nächstes Thema

CoolTux

OK dann bleibt noch die Sache mit HTTP. Ich könnte da jetzt ein Attribut machen, muss aber gestehen ich tue mich da sehr schwer mit eine solche Verbindung mit Passwort-Übergabe ohne Verschlüsselung zu machen. Egal ob eigenes Netz oder nicht. Meine Empfehlung ist daher auf jeden Fall auf HTTPS um zu stellen, auch intern.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

tomspatz

Das wäre zumindest einen Versuch wert. Ob und wie es jemand benutzt wäre ja nicht dein Bier ;)
Sehr gerne teste wenn du es schaffst es umzubauen.

LG Tom

@fr00sch ist es bei dir ggf. auch so ??

CoolTux

Ich werde es heute Abend mal umbauen. Werde es aber nicht dokumentieren.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

CoolTux

Ich habe ein zusätzliches Attribut namens proto eingerichtet. Dort kann man einzig und allein http auswählen. Wenn man das nicht mehr will muss das Attribut gelöscht werden.
Bitte update machen und testen.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

antonwinden

Danke für das Modul - funktioniert bei mir gut.
Gibt es die Möglichkeit auch die Anzahl der Backups zu begrenzen - soll heißen nur z.B. die letzten 7 behalten und den Rest löschen?
gruß anton
KNX, Raspberry, Denon 3313, Philips TV, Xtrend9X00 und viel Optimismus...

tomspatz

Zitat von: CoolTux am 20 Oktober 2020, 15:53:56
Ich habe ein zusätzliches Attribut namens proto eingerichtet. Dort kann man einzig und allein http auswählen. Wenn man das nicht mehr will muss das Attribut gelöscht werden.
Bitte update machen und testen.

2020.10.20 18:48:30 4: backupToStorage (myNextcloudUpload) - Read password from file
2020.10.20 18:48:32 4: backupToStorage (myNextcloudUpload) - Read password from file
2020.10.20 18:48:32 4: backupToStorage (myNextcloudUpload) - Read password from file
2020.10.20 18:49:23 2: backup include:
2020.10.20 18:49:23 2: backup include:
2020.10.20 18:49:23 2: Backup with command: tar czf ./backup/FHEM-20201020_184923.tar.gz "./demolog" "./fhem.cfg.demo" "./FHEM" "./restoreDir" "./fhem.pl" "./MAINTAINER.txt" "./README_DEMO.txt" "./docs" "./log" "./CHANGED" "./fhem.cfg" "./configDB.pm" "./www" "./contrib" "./lib"
Backup done
2020.10.20 18:49:51 4: backupToStorage (myNextcloudUpload) - Devname: global Name: myNextcloudUpload Notify: $VAR1 = [
          'backup done'
        ];

2020.10.20 18:49:51 4: backupToStorage (myNextcloudUpload) - push to storage function
2020.10.20 18:49:51 4: backupToStorage (myNextcloudUpload) - after readings age return
2020.10.20 18:49:51 4: backupToStorage (myNextcloudUpload) - Read password from file
2020.10.20 18:49:51 4: backupToStorage (myNextcloudUpload) - Devname: myNextcloudUpload Name: myNextcloudUpload Notify: $VAR1 = [
          'state:  file upload in progress'
        ];

2020.10.20 18:49:51 4: backupToStorage (myNextcloudUpload) - execute command asynchronously (PID=8893)
2020.10.20 18:49:51 4: backupToStorage (myNextcloudUpload) - control passed back to main loop.
2020.10.20 18:49:52 5: backupToStorage (myNextcloudUpload) - still waiting (read: no data).
2020.10.20 18:49:53 5: backupToStorage (myNextcloudUpload) - still waiting (read: no data).
2020.10.20 18:49:54 5: backupToStorage (myNextcloudUpload) - still waiting (read: no data).
2020.10.20 18:49:55 5: backupToStorage (myNextcloudUpload) - still waiting (read: no data).
2020.10.20 18:49:56 5: backupToStorage (myNextcloudUpload) - still waiting (read: no data).
2020.10.20 18:49:57 4: backupToStorage (myNextcloudUpload) - got result from asynchronous parsing.
2020.10.20 18:49:57 4: backupToStorage (myNextcloudUpload) - asynchronous finished.
2020.10.20 18:49:57 4: backupToStorage (myNextcloudUpload) - clean Subprocess
2020.10.20 18:49:57 4: backupToStorage (myNextcloudUpload) - Devname: myNextcloudUpload Name: myNextcloudUpload Notify: $VAR1 = [
          'state: ready',
          'uploadState: upload successfully'
        ];



Internals:
   FUUID      5f8c60da-f33f-a28b-3e51-7fca3212df09c53a
   NAME       myNextcloudUpload
   NOTIFYDEV  global,myNextcloudUpload
   NR         19
   NTFY_ORDER 51-myNextcloudUpload
   STATE      ready
   STORAGETYPE Nextcloud
   TYPE       backupToStorage
   VERSION    v1.1.0
   READINGS:
     2020-10-20 18:49:23   fhemBackupFile  ./backup/FHEM-20201020_184923.tar.gz
     2020-10-20 18:49:57   state           ready
     2020-10-20 18:49:57   uploadState     upload successfully
Attributes:
   bTS_Host   nextcloud.xxxxx.de
   bTS_Path   /FHEM-Backup
   bTS_Proto  http
   bTS_User   fhem
   verbose    5


leider nicht, wenn ich allerdings es so versuche:
bTS_Host   192.168.1.95:443
so komme ich im browser auch auf die web Oberfläche der NC, habe ich zumindesteine veränderung im log:
2020.10.20 18:53:10 2: backup include:
2020.10.20 18:53:10 2: backup include:
2020.10.20 18:53:10 2: Backup with command: tar czf ./backup/FHEM-20201020_185310.tar.gz "./fhem.cfg.demo" "./demolog" "./fhem.pl" "./restoreDir" "./FHEM" "./fhem.cfg" "./CHANGED" "./docs" "./log" "./MAINTAINER.txt" "./README_DEMO.txt" "./lib" "./www" "./configDB.pm" "./contrib"
Backup done
2020.10.20 18:53:38 4: backupToStorage (myNextcloudUpload) - Devname: global Name: myNextcloudUpload Notify: $VAR1 = [
          'backup done'
        ];

2020.10.20 18:53:38 4: backupToStorage (myNextcloudUpload) - push to storage function
2020.10.20 18:53:38 4: backupToStorage (myNextcloudUpload) - after readings age return
2020.10.20 18:53:38 4: backupToStorage (myNextcloudUpload) - Read password from file
2020.10.20 18:53:38 4: backupToStorage (myNextcloudUpload) - Devname: myNextcloudUpload Name: myNextcloudUpload Notify: $VAR1 = [
          'state:  file upload in progress'
        ];

2020.10.20 18:53:38 4: backupToStorage (myNextcloudUpload) - execute command asynchronously (PID=8905)
2020.10.20 18:53:38 4: backupToStorage (myNextcloudUpload) - control passed back to main loop.
2020.10.20 18:53:39 4: backupToStorage (myNextcloudUpload) - got result from asynchronous parsing.
2020.10.20 18:53:39 4: backupToStorage (myNextcloudUpload) - asynchronous finished.
2020.10.20 18:53:39 4: backupToStorage (myNextcloudUpload) - clean Subprocess
2020.10.20 18:53:39 4: backupToStorage (myNextcloudUpload) - Devname: myNextcloudUpload Name: myNextcloudUpload Notify: $VAR1 = [
          'state: ready',
          'uploadState: <html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>nginx/1.16.1</center>
</body>
</html>
'
        ];


Ich weiss deine Arbeit echt zu schätzen aber das hier ist doch sehr speziell, vielleicht sollte ich lieber unsere UTM anders programmieren.
LG
Tom

CoolTux

Das man eine entsprechende Meldung bekommt wenn man http als Protokoll angibt dann aber auf den SSL Port eine Anfrage schickt ist ja normal.
Irgendwie seltsam das es nicht eine Fehlermeldung gibt. Wenn Du noch Lust hast zum testen würde ich mal schauen das ich versuche als Log Ausgabe das Ergebnis des Kommandos aus zu geben.
Irgendwo muss ja stehen was er da genau für Probleme hat  ;D
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

fr00sch

Zitat von: CoolTux am 20 Oktober 2020, 10:43:21
Sieht eigentlich gut aus. Im angegebenen Ordner liegt aber kein File?
Ja, der Ordner bleibt leider leer.
Ich habe erfolglos noch etwas herum probiert:
- andere Ordner Namen
- Hauptverzeichnis

Aber nachdem ich mir hier die Upload-Zeiten angesehen habe, glaube ich eher, dass gar nichts hochgeladen wird:

        ];
          'uploadState: upload successfully'
          'state: ready',
2020.10.21 08:16:33 4:  backupToStorage (myNextcloudUpload) - Devname: myNextcloudUpload Name: myNextcloudUpload Notify: $VAR1 = [
2020.10.21 08:16:33 4:  backupToStorage (myNextcloudUpload) - clean Subprocess
2020.10.21 08:16:33 4:  backupToStorage (myNextcloudUpload) - asynchronous finished.
2020.10.21 08:16:32 4:  backupToStorage (myNextcloudUpload) - got result from asynchronous parsing: {"ncUpload":"upload successfully"}
2020.10.21 08:16:31 4:  backupToStorage (myNextcloudUpload) - control passed back to main loop.
2020.10.21 08:16:31 4:  backupToStorage (myNextcloudUpload) - execute command asynchronously (PID=29103)

        ];
          'state:  file upload in progress'
2020.10.21 08:16:31 4:  backupToStorage (myNextcloudUpload) - Devname: myNextcloudUpload Name: myNextcloudUpload Notify: $VAR1 = [
2020.10.21 08:16:31 4:  backupToStorage (myNextcloudUpload) - Read password from file
2020.10.21 08:16:31 4:  backupToStorage (myNextcloudUpload) - after readings age return
2020.10.21 08:16:31 4:  backupToStorage (myNextcloudUpload) - push to storage function

        ];
          'backup done'
2020.10.21 08:16:31 4:  backupToStorage (myNextcloudUpload) - Devname: global Name: myNextcloudUpload Notify: $VAR1 = [

Innerhalb von 2 Sekunden sind die 87MB sicherlich nicht hochgeladen  ???
Da hilft dann vermutlich die Log-Ausgabe des Upload-Kommandos.

Die Variante mit http kann ich bei mir leider nicht testen.
Ich habe geschaut ob alle notwendigen Paket da sind und es sieht soweit gut aus.

Dankeschön für deine Mühe.
RPi3B+ als FHEM mit VCCU,ZWave,Signalduino,MQTT
RPi4B als CCU3
QNAP TS451p(mit Docker) als Messwerte-Datenbank

tomspatz

Zitat von: CoolTux am 20 Oktober 2020, 19:52:37
Das man eine entsprechende Meldung bekommt wenn man http als Protokoll angibt dann aber auf den SSL Port eine Anfrage schickt ist ja normal.
Irgendwie seltsam das es nicht eine Fehlermeldung gibt. Wenn Du noch Lust hast zum testen würde ich mal schauen das ich versuche als Log Ausgabe das Ergebnis des Kommandos aus zu geben.
Irgendwo muss ja stehen was er da genau für Probleme hat  ;D
Moin
Ja sehr gerne. Gib einfach laut was du noch an Infos brauchst.

CoolTux

So ihr beiden. Ich habe jetzt mal genau an der Stelle ein Log eingebaut wo die Rückgabe des Hochladebefehls kommt. So ganz ohne Auswertung. Quasi pur. Bitte dafür das verbose Attribut im Device auf 5 stellen und dann noch mal testen bitte. Ich brauche dann den Logauszug. Danke Euch.


Grüße
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

HeikoGr

ich möchte die aktuelle Analyse ungern unterbrechen, aber wäre es evtl. möglich oder sinnvoll das Skript zu erweitern, sodass configDB und DbRep Backups auch weggesichert werden können?

Es wäre eine schöne All-in-one Backup Lösung  8)

CoolTux

Zitat von: HeikoGr am 21 Oktober 2020, 09:41:16
ich möchte die aktuelle Analyse ungern unterbrechen, aber wäre es evtl. möglich oder sinnvoll das Skript zu erweitern, sodass configDB und DbRep Backups auch weggesichert werden können?

Es wäre eine schöne All-in-one Backup Lösung  8)

Zu mindest configDB hat bereits eine Backupfunktion.
Ich denke gerade im Bereich Datenbank ist eine individuelle Lösung besser geeignet. Spreche da aus Erfahrung  :)
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

HeikoGr

ich habe auch gerade festgestellt, dass sowohl configdb als auch DbRep ins log Verzeichnis dumpen (können). Da das Verzeichnis Teil des backups ist reicht mir das sogar.

Ich würde dir gerne teilweise widersprechen:
Ein einzelnes Backup mit konsistenten Datenständen würde ich bevorzugen. Zumal jedes eingerichtete Backupverfahren selbst konfiguriert werden muss. Das eine Verfahren kann auf Diskstations schreiben, ein anderes nur lokal und deines in eine nextcloud. Das macht es nicht einfacher   ;)

CoolTux

Zitat von: HeikoGr am 21 Oktober 2020, 09:55:45
ich habe auch gerade festgestellt, dass sowohl configdb als auch DbRep ins log Verzeichnis dumpen (können). Da das Verzeichnis Teil des backups ist reicht mir das sogar.

Ich würde dir gerne teilweise widersprechen:
Ein einzelnes Backup mit konsistenten Datenständen würde ich bevorzugen. Zumal jedes eingerichtete Backupverfahren selbst konfiguriert werden muss. Das eine Verfahren kann auf Diskstations schreiben, ein anderes nur lokal und deines in eine nextcloud. Das macht es nicht einfacher   ;)

Meine Aussage bezog sich ja auf Datenbanken. Eigentlich wollte und will ich das Modul ja ausbauen so das nicht nur auf Nestcloud sondern auch auf Diskstations gesichert werden kann.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

fr00sch

Zitat von: CoolTux am 21 Oktober 2020, 09:25:58
So ihr beiden. Ich habe jetzt mal genau an der Stelle ein Log eingebaut wo die Rückgabe des Hochladebefehls kommt. So ganz ohne Auswertung. Quasi pur. Bitte dafür das verbose Attribut im Device auf 5 stellen und dann noch mal testen bitte. Ich brauche dann den Logauszug. Danke Euch.


Grüße

Ich hab den Test gemacht:

        ];
          'uploadState: upload successfully'
          'state: ready',
2020.10.21 09:45:55 4:  backupToStorage (myNextcloudUpload) - Devname: myNextcloudUpload Name: myNextcloudUpload Notify: $VAR1 = [
2020.10.21 09:45:55 4:  backupToStorage (myNextcloudUpload) - clean Subprocess
2020.10.21 09:45:55 4:  backupToStorage (myNextcloudUpload) - asynchronous finished.
2020.10.21 09:45:55 4:  backupToStorage (myNextcloudUpload) - got result from asynchronous parsing: {"ncUpload":"upload successfully"}
backupToStorage File Upload - FileUpload Nextcloud, returnCode: 72057594037927935 , returnString:
2020.10.21 09:45:54 4:  backupToStorage (myNextcloudUpload) - control passed back to main loop.
2020.10.21 09:45:54 4:  backupToStorage (myNextcloudUpload) - execute command asynchronously (PID=9863)

        ];
          'state:  file upload in progress'
2020.10.21 09:45:54 4:  backupToStorage (myNextcloudUpload) - Devname: myNextcloudUpload Name: myNextcloudUpload Notify: $VAR1 = [
2020.10.21 09:45:53 4:  backupToStorage (myNextcloudUpload) - Read password from file
2020.10.21 09:45:53 4:  backupToStorage (myNextcloudUpload) - after readings age return
2020.10.21 09:45:53 4:  backupToStorage (myNextcloudUpload) - push to storage function

        ];
          'backup done'
2020.10.21 09:45:53 4:  backupToStorage (myNextcloudUpload) - Devname: global Name: myNextcloudUpload Notify: $VAR1 = [
Backup done


Ich habe den Test nochmal wiederholt:

        ];
          'uploadState: upload successfully'
          'state: ready',
2020.10.21 10:00:06 4:  backupToStorage (myNextcloudUpload) - Devname: myNextcloudUpload Name: myNextcloudUpload Notify: $VAR1 = [
2020.10.21 10:00:06 4:  backupToStorage (myNextcloudUpload) - clean Subprocess
2020.10.21 10:00:06 4:  backupToStorage (myNextcloudUpload) - asynchronous finished.
2020.10.21 10:00:06 4:  backupToStorage (myNextcloudUpload) - got result from asynchronous parsing: {"ncUpload":"upload successfully"}
backupToStorage File Upload - FileUpload Nextcloud, returnCode: 72057594037927935 , returnString:
2020.10.21 10:00:04 5:  backupToStorage (myNextcloudUpload) - still waiting (read: no data).
2020.10.21 10:00:03 5:  backupToStorage (myNextcloudUpload) - still waiting (read: no data).
2020.10.21 10:00:02 4:  backupToStorage (myNextcloudUpload) - control passed back to main loop.
2020.10.21 10:00:02 4:  backupToStorage (myNextcloudUpload) - execute command asynchronously (PID=11878)
2020.10.21 10:00:02 4:  backupToStorage (myNextcloudUpload) - Read password from file

        ];
          'state:  file upload in progress'
2020.10.21 10:00:02 4:  backupToStorage (myNextcloudUpload) - Devname: myNextcloudUpload Name: myNextcloudUpload Notify: $VAR1 = [
2020.10.21 10:00:01 4:  backupToStorage (myNextcloudUpload) - Read password from file
2020.10.21 10:00:00 4:  backupToStorage (myNextcloudUpload) - after readings age return
2020.10.21 10:00:00 4:  backupToStorage (myNextcloudUpload) - push to storage function

        ];
          'backup done'
2020.10.21 10:00:00 4:  backupToStorage (myNextcloudUpload) - Devname: global Name: myNextcloudUpload Notify: $VAR1 = [
Backup done

Da sind wenigstens Infos im LogLevel 5 dabei  ???

Allerdings habe ich seit heute morgen folgenden Text im Update-Log drinnen

2020.10.21 09:41:13 1:  ... rest of lines skipped.
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1:  }
2020.10.21 09:41:12 1:  });
2020.10.21 09:41:12 1:  console.info('ServiceWorker registration failed: ', err);
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1:  }, function(err) {
2020.10.21 09:41:12 1:  console.info('ServiceWorker registration successful with scope: ', registration.scope);
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1:  navigator.serviceWorker.register('/serviceworker.js').then(function(registration) {
2020.10.21 09:41:12 1:  if ('serviceWorker' in navigator) {
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1:  New entries in the CHANGED file:
2020.10.21 09:41:12 1: 
2020.10.21 09:41:12 1:  UPD lib/FHEM/backupToStorage.pm
2020.10.21 09:41:08 1:  backupToStorage
2020.10.21 09:41:08 1: 
2020.10.21 09:41:08 1:  Downloading https://git.cooltux.net/FHEM/mod-backupToStorage/raw/branch/testing/controls_backupToStorage.txt

Ist vermutlich nicht das Problem aber eventuell ein Punkt zur Verbesserung.

Gruß

RPi3B+ als FHEM mit VCCU,ZWave,Signalduino,MQTT
RPi4B als CCU3
QNAP TS451p(mit Docker) als Messwerte-Datenbank