From a6300aac34ebeca228fa33d0fb8883fe446ca34c Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Sat, 14 Jul 2018 19:27:51 +0200 Subject: [PATCH 1/3] ### 0.2.0 (14.07.2018) * (blufox) Code formatting --- README.md | 2 + admin/index_m.html | 706 ++++++++++++++++++++++----------------------- admin/words.js | 16 +- backitup.sh | 1 - io-package.json | 40 ++- main.js | 429 +++++++++++++-------------- package.json | 8 +- 7 files changed, 591 insertions(+), 611 deletions(-) diff --git a/README.md b/README.md index 2e996896..b0194e52 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,8 @@ Unter DOS wird in Textdateien ein Zeilenende durch die Sequenz return (Dezimalco Einige Benutzer berichteten dass das IoBroker komplett-Backup nicht richtig durchläuft bzw. der IoBroker gestoppt und nicht mehr gestartet wird. Hierfür ist es möglich in der Adapter- Konfigurations-Datenpunkten den Stop/Start des IoBrokers beim komplett-Backup zu deaktivieren. ## Changelog +### 0.2.0 (14.07.2018) + * (blufox) Code formatting ### 0.1.8 (11.07.2018) * (darkiop) MySQL-Sicherung um Host- und Portabfrage erweitert diff --git a/admin/index_m.html b/admin/index_m.html index 14d5b3d1..bd2c1f76 100644 --- a/admin/index_m.html +++ b/admin/index_m.html @@ -1,416 +1,406 @@ - - - + + + - - + + - - - - - - - - + + + + + + -
- -
+
+
-
-
- -
-
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
+
+
+
+ +
-
- -
-
- - - Anzahl der History-Eintraege +
+
+ + +
+
+ + +
-
-
- - -
-
-
- - -
-
-
-
- - - Backup Startzeit in hh:mm +
+
+ + +
+
+ + +
-
- - - Backup ausfuehren alle X-Tage +
+
+ + +
+
+ + +
-
- - - alte Standard-Backups loeschen nach X-Tagen +
+
+ + + Anzahl der History-Eintraege +
-
- - - NamensZusatz -
-
-
- - -
-
-
- - -
-
-
- - - Backup Startzeit in hh:mm -
-
- - - Backup ausfuehren alle X-Tage -
-
- - - alte Komplett-Backups loeschen nach X-Tagen + + +
+
+
+ + +
-
- - - NamensZusatz +
+
+ + + Backup Startzeit in hh:mm +
+
+ + + Backup ausfuehren alle X-Tage +
+
+ + + alte Standard-Backups loeschen nach X-Tagen +
+
+ + + NamensZusatz +
-
- - -
-
-
- - - MySQL Hostname -
-
- - - MySQL Port -
-
- - - MySQL Datenbank Name + + +
+
+
+ + +
-
-
-
- - - MySql Benutzername +
+
+ + + Backup Startzeit in hh:mm +
+
+ + + Backup ausfuehren alle X-Tage +
+
+ + + alte Komplett-Backups loeschen nach X-Tagen +
+
+ + + NamensZusatz +
-
- - - MySql Passwort -
-
- - - alte MySQL Backups loeschen nach X-Tagen -
-
-
- - -
-
-
- - -
-
-
- - - Backup Startzeit in hh:mm + + +
+
+
+ + + MySQL Hostname +
+
+ + + MySQL Port +
+
+ + + MySQL Datenbank Name +
-
- - - Backup ausfuehren alle X-Tage +
+
+ + + MySql Benutzername +
+
+ + + MySql Passwort +
+
+ + + alte MySQL Backups loeschen nach X-Tagen +
-
- - - alte CCU-Backups loeschen nach X-Tagen -
-
-
-
- - - IP der CCU + + +
+
+
+ + +
-
- - - Benutzername der CCU +
+
+ + + Backup Startzeit in hh:mm +
+
+ + + Backup ausfuehren alle X-Tage +
+
+ + + alte CCU-Backups loeschen nach X-Tagen +
+
-
- - - Passwort der CCU +
+
+ + + IP der CCU +
+
+ + + Benutzername der CCU +
+
+ + + Passwort der CCU +
-
- - -
-
-
- - -
-
-
-
- -
-
- - - Host + + +
+
+
+ + +
-
- - - Benutzername +
-
- - - Passwort + +
+
+ + + Host +
+
+ + + Benutzername +
+
+ + + Passwort +
-
- -
-
- - -
-
-
-
- - - Pfad fuer Standard-Backup -
-
- - - Pfad fuer Komplett-Backup +
+
+ + +
-
- - - Pfad fuer CCU-Backup -
-
-
-
- - - Pfad +
+
+ + + Pfad fuer Standard-Backup +
+
+ + + Pfad fuer Komplett-Backup +
+
+ + + Pfad fuer CCU-Backup +
-
-
- +
+
+ + + Pfad +
+
+
+
+
diff --git a/admin/words.js b/admin/words.js index e5ca266f..d7a699dd 100644 --- a/admin/words.js +++ b/admin/words.js @@ -3,11 +3,11 @@ systemDictionary = { "Anzahl der History-Eintraege": { "en": "Number of history entries", "de": "Anzahl der History-Einträge", "ru": "Количество записей в истории", "pt": "Número de entradas do histórico", "nl": "Aantal geschiedenisitems", "fr": "Nombre d'entrées d'historique", "it": "Numero di voci della cronologia", "es": "Número de entradas de historial", "pl": "Liczba wpisów historii"}, - "Backup Startzeit in hh:mm": { "en": "Backup start time in hh: mm", "de": "Backup Startzeit in hh:mm", "ru": "Время начала резервного копирования в чч: мм", "pt": "Horário de início de backup em hh: mm", "nl": "Backup starttijd in uu: mm", "fr": "Heure de début de sauvegarde en hh: mm", "it": "Ora di inizio backup in hh: mm", "es": "Tiempo de inicio de respaldo en hh: mm", "pl": "Czas uruchomienia kopii zapasowej w gg: mm"}, + "Backup Startzeit in hh:mm": { "en": "Backup start time in hh: mm", "de": "Backup Startzeit in hh:mm", "ru": "Время начала резервного копирования в чч:мм", "pt": "Horário de início de backup em hh: mm", "nl": "Backup starttijd in uu: mm", "fr": "Heure de début de sauvegarde en hh: mm", "it": "Ora di inizio backup in hh: mm", "es": "Tiempo de inicio de respaldo en hh: mm", "pl": "Czas uruchomienia kopii zapasowej w gg: mm"}, "Backup ausfuehren alle X-Tage": { "en": "Backup will run every X days", "de": "Backup ausführen alle X-Tage", "ru": "Резервное копирование выполняется каждые X дней", "pt": "Backup executado a cada X dias", "nl": "Back-up wordt elke X dagen uitgevoerd", "fr": "Sauvegarde exécutée tous les X jours", "it": "Esegui il backup ogni X giorni", "es": "Ejecución de respaldo cada X días", "pl": "Backup uruchamiany co X dni"}, "Backupzeit": { "en": "backup time", "de": "Backupzeit", "ru": "время резервного копирования", "pt": "tempo de backup", "nl": "back-up tijd", "fr": "temps de sauvegarde", "it": "tempo di backup", "es": "tiempo de respaldo", "pl": "czas podtrzymania"}, - "Benachrichtigungen per Telegram": { "en": "Notifications by telegram", "de": "Benachrichtigungen per Telegram", "ru": "Уведомления по телеграмме", "pt": "Notificações por telegrama", "nl": "Meldingen per telegram", "fr": "Notifications par télégramme", "it": "Notifiche via telegramma", "es": "Notificaciones por telegrama", "pl": "Powiadomienia za pomoca telegramu"}, - "Telegram Instanz": { "en": "Telegram instance", "de": "Telegram Instanz", "ru": "Экземпляр телеграмме", "pt": "Instância do telegrama", "nl": "Telegram-instantie", "fr": "Instance de télégramme", "it": "Istanza di Telegram", "es": "Instancia de Telegram", "pl": "Instancja telegramu"}, + "Benachrichtigungen per Telegram": { "en": "Notifications by telegram", "de": "Benachrichtigungen per Telegram", "ru": "Уведомления в телеграм", "pt": "Notificações por telegrama", "nl": "Meldingen per telegram", "fr": "Notifications par télégramme", "it": "Notifiche via telegramma", "es": "Notificaciones por telegrama", "pl": "Powiadomienia za pomoca telegramu"}, + "Telegram Instanz": { "en": "Telegram instance", "de": "Telegram Instanz", "ru": "Экземпляр телеграм", "pt": "Instância do telegrama", "nl": "Telegram-instantie", "fr": "Instance de télégramme", "it": "Istanza di Telegram", "es": "Instancia de Telegram", "pl": "Instancja telegramu"}, "Benutzername": { "en": "Username", "de": "Benutzername", "ru": "имя пользователя", "pt": "nome de usuário", "nl": "gebruikersnaam", "fr": "nom d'utilisateur", "it": "nome utente", "es": "nombre de usuario", "pl": "nazwa uzytkownika"}, "Benutzername der CCU": { "en": "Username of the CCU", "de": "Benutzername der CCU", "ru": "Имя пользователя CCU", "pt": "Nome de usuário da CCU", "nl": "Gebruikersnaam van de CCU", "fr": "Nom d'utilisateur du CCU", "it": "Nome utente del CCU", "es": "Nombre de usuario de la CCU", "pl": "Nazwa uzytkownika CCU"}, "CCU Backup": { "en": "CCU Backup", "de": "CCU Backup", "ru": "Резервное копирование CCU", "pt": "Backup de CCU", "nl": "CCU-back-up", "fr": "Sauvegarde CCU", "it": "Backup CCU", "es": "Copia de seguridad CCU", "pl": "Kopie zapasowe CCU"}, @@ -15,9 +15,9 @@ systemDictionary = { "Debug aktivieren/deaktivieren": { "en": "Enable / disable debug", "de": "Debug aktivieren / deaktivieren", "ru": "Включение / отключение отладки", "pt": "Ativar / desativar a depuração", "nl": "Schakel foutopsporing in / uit", "fr": "Activer / désactiver le débogage", "it": "Abilita / disabilita il debug", "es": "Habilitar / deshabilitar la depuración", "pl": "Wlacz / wylacz debugowanie"}, "Extra Pfad fuer Backuptypen": { "en": "Extra path for backup types", "de": "Extrapfade für alle Backuptypen", "ru": "Дополнительные пути для всех типов резервных копий", "pt": "Caminhos extras para todos os tipos de backups", "nl": "Extra paden voor alle soorten back-ups", "fr": "Chemins supplémentaires pour tous les types de sauvegardes", "it": "Percorsi aggiuntivi per tutti i tipi di backup", "es": "Rutas adicionales para todos los tipos de copias de seguridad", "pl": "Dodatkowe sciezki dla wszystkich typów kopii zapasowych"}, "FTP": { "en": "FTP", "de": "FTP", "ru": "FTP", "pt": "FTP", "nl": "FTP", "fr": "FTP", "it": "FTP", "es": "FTP", "pl": "FTP"}, - "Haupteinstellungen": { "en": "main settings", "de": "Haupteinstellungen", "ru": "Основные настройки", "pt": "configurações principais", "nl": "belangrijkste instellingen", "fr": "principaux paramètres", "it": "impostazioni principali", "es": "configuraciones principales", "pl": "Glówne ustawienia"}, + "Haupteinstellungen": { "en": "main settings", "de": "Haupteinstellungen", "ru": "Основные", "pt": "configurações principais", "nl": "belangrijkste instellingen", "fr": "principaux paramètres", "it": "impostazioni principali", "es": "configuraciones principales", "pl": "Glówne ustawienia"}, "Homematic-CCU Backup": { "en": "Homematic CCU backup", "de": "Homematic-CCU Backup", "ru": "Резервное копирование Homematic CCU", "pt": "Backup homematic CCU", "nl": "Homematische CCU-back-up", "fr": "Sauvegarde CCU homématique", "it": "Backup CCU omni stico", "es": "Copia de seguridad CCM de Homematic", "pl": "Kopia zapasowa homematic CCU"}, - "Host": { "en": "Host", "de": "Host", "ru": "хозяин", "pt": "anfitrião", "nl": "gastheer", "fr": "hôte", "it": "ospite", "es": "anfitrión", "pl": "gospodarz"}, + "Host": { "en": "Host", "de": "Host", "ru": "Хост", "pt": "anfitrião", "nl": "gastheer", "fr": "hôte", "it": "ospite", "es": "anfitrión", "pl": "gospodarz"}, "IP der CCU": { "en": "IP of the CCU", "de": "IP-Adresse der CCU", "ru": "IP-адрес CCU", "pt": "Endereço IP da CCU", "nl": "IP-adres van de CCU", "fr": "Adresse IP de la CCU", "it": "Indirizzo IP della CCU", "es": "Dirección IP de la CCU", "pl": "Adres IP komputera kursowego"}, "IP-Adresse": { "en": "IP address", "de": "IP-Adresse", "ru": "IP-адрес", "pt": "endereço IP", "nl": "IP-adres", "fr": "adresse IP", "it": "indirizzo IP", "es": "dirección IP", "pl": "adres IP"}, "Komplett Backup": { "en": "Complete backup", "de": "Komplett Backup", "ru": "Полная копия", "pt": "Backup completo", "nl": "Volledige back-up", "fr": "Sauvegarde complète", "it": "Backup completo", "es": "Respaldo completo", "pl": "Wykonaj pelna kopie zapasowa"}, @@ -38,13 +38,13 @@ systemDictionary = { "Pfad fuer CCU-Backup": { "en": "Path for CCU backup", "de": "NAS-Pfad für CCU-Backup", "ru": "Путь NAS для резервного копирования CCU", "pt": "Caminho do NAS para backup de CCU", "nl": "NAS-pad voor CCU-back-up", "fr": "Chemin NAS pour la sauvegarde CCU", "it": "Percorso NAS per backup CCU", "es": "Ruta NAS para copia de seguridad de CCU", "pl": "Sciezka NAS do tworzenia kopii zapasowych CCU"}, "Pfad fuer Komplett-Backup": { "en": "Path for complete backup", "de": "NAS-Pfad für Komplett-Backup", "ru": "Путь NAS для полной резервной копии", "pt": "Caminho NAS para backup completo", "nl": "NAS-pad voor volledige back-up", "fr": "Chemin NAS pour une sauvegarde complète", "it": "Percorso NAS per backup completo", "es": "Ruta NAS para copia de seguridad completa", "pl": "Sciezka NAS do pelnej kopii zapasowej"}, "Pfad fuer Standard-Backup": { "en": "Path for standard backup", "de": "NAS-Pfad für Standard-Backup", "ru": "Путь NAS для стандартной резервной копии", "pt": "Caminho NAS para backup padrão", "nl": "NAS-pad voor standaardback-up", "fr": "Chemin NAS pour la sauvegarde standard", "it": "Percorso NAS per backup standard", "es": "Ruta NAS para copia de seguridad estándar", "pl": "Sciezka NAS do standardowej kopii zapasowej"}, - "Redis Status sichern": { "en": "Save Redis state", "de": "Redis Status sichern", "ru": "Сохранить статус Redis", "pt": "Salvar status do Redis", "nl": "Redis-status opslaan", "fr": "Enregistrer le statut Redis", "it": "Salva stato Redis", "es": "Guardar el estado de Redis", "pl": "Zapisz status Redis"}, + "Redis Status sichern": { "en": "Save Redis state", "de": "Redis Status sichern", "ru": "Сохранить статусы из Redis", "pt": "Salvar status do Redis", "nl": "Redis-status opslaan", "fr": "Enregistrer le statut Redis", "it": "Salva stato Redis", "es": "Guardar el estado de Redis", "pl": "Zapisz status Redis"}, "Standard Backup": { "en": "Standard backup", "de": "Standard Backup", "ru": "Стандартное резервирование", "pt": "Backup padrão", "nl": "Standaard back-up", "fr": "Sauvegarde standard", "it": "Backup standard", "es": "Copia de seguridad estándar", "pl": "Standardowa kopia zapasowa"}, - "Stop ioBroker bei Backup": { "en": "Stop ioBroker at backup", "de": "ioBroker Stop bei einem Backup", "ru": "ioBroker останавливается во время резервного копирования", "pt": "ioBroker parar durante um backup", "nl": "ioBroker stopt tijdens een back-up", "fr": "ioBroker s'arrête pendant une sauvegarde", "it": "ioBroker si ferma durante un backup", "es": "ioBroker se detiene durante una copia de seguridad", "pl": "Zatrzymanie ioBroker podczas tworzenia kopii zapasowej"}, + "Stop ioBroker bei Backup": { "en": "Stop ioBroker at backup", "de": "ioBroker Stop bei einem Backup", "ru": "Останавливать ioBroker во время резервного копирования", "pt": "ioBroker parar durante um backup", "nl": "ioBroker stopt tijdens een back-up", "fr": "ioBroker s'arrête pendant une sauvegarde", "it": "ioBroker si ferma durante un backup", "es": "ioBroker se detiene durante una copia de seguridad", "pl": "Zatrzymanie ioBroker podczas tworzenia kopii zapasowej"}, "Tage": { "en": "days", "de": "Tage", "ru": "дней", "pt": "dias", "nl": "dagen", "fr": "journées", "it": "giorni", "es": "días", "pl": "dni"}, "Verbindungstyp": { "en": "connection type", "de": "Verbindungstyp", "ru": "Тип подключения", "pt": "tipo de conexão", "nl": "verbindingstype", "fr": "type de connexion", "it": "tipo di connessione", "es": "tipo de conexión", "pl": "Typ polaczenia"}, "alte CCU-Backups loeschen nach X-Tagen": { "en": "Old CCU backups delete after X days", "de": "alte CCU-Backups löschen nach X-Tagen", "ru": "Удаление старых резервных копий CCU после X дней", "pt": "Excluir backups de CCU antigos após X dias", "nl": "Oude XU-back-ups na X dagen verwijderen", "fr": "Supprimer les anciennes sauvegardes CCU après X jours", "it": "Elimina vecchi backup CCU dopo X giorni", "es": "Eliminar copias de seguridad CCU anteriores después de X días", "pl": "Usun stare kopie zapasowe CCU po X dniach"}, "alte Komplett-Backups loeschen nach X-Tagen": { "en": "old complete backups delete after X days", "de": "alte Komplett-Backups löschen nach X-Tagen", "ru": "удалить старые полные резервные копии после X дней", "pt": "excluir backups completos antigos após X dias", "nl": "verwijder oude volledige back-ups na X dagen", "fr": "supprimer les anciennes sauvegardes complètes après X jours", "it": "cancella vecchi backup completi dopo X giorni", "es": "eliminar viejas copias de seguridad completas después de X días", "pl": "usun stare pelne kopie zapasowe po X dniach"}, "alte MySQL Backups loeschen nach X-Tagen": { "en": "old MySQL backups delete after X days", "de": "alte MySQL Backups löschen nach X-Tagen", "ru": "удалить старые резервные копии MySQL после X дней", "pt": "excluir backups antigos do MySQL após X dias", "nl": "verwijder oude MySQL-back-ups na X dagen", "fr": "supprimer les anciennes sauvegardes MySQL après X jours", "it": "cancella i vecchi backup MySQL dopo X giorni", "es": "eliminar viejas copias de seguridad de MySQL después de X días", "pl": "usun stare kopie zapasowe MySQL po X dniach"}, - "alte Standard-Backups loeschen nach X-Tagen": { "en": "old standard backups delete after X-days", "de": "alte Standard-Backups löschen nach X-Tagen", "ru": "удалить старые стандартные резервные копии после X дней", "pt": "excluir backups padrão antigos após X dias", "nl": "verwijder oude standaardback-ups na X dagen", "fr": "supprimer les anciennes sauvegardes standard après X jours", "it": "cancella i vecchi backup standard dopo X giorni", "es": "eliminar copias de seguridad estándar antiguas después de X días", "pl": "usuwaj stare standardowe kopie zapasowe po X dniach"}, + "alte Standard-Backups loeschen nach X-Tagen": { "en": "old standard backups delete after X-days", "de": "alte Standard-Backups löschen nach X-Tagen", "ru": "удалить старые стандартные резервные копии после X дней", "pt": "excluir backups padrão antigos após X dias", "nl": "verwijder oude standaardback-ups na X dagen", "fr": "supprimer les anciennes sauvegardes standard après X jours", "it": "cancella i vecchi backup standard dopo X giorni", "es": "eliminar copias de seguridad estándar antiguas después de X días", "pl": "usuwaj stare standardowe kopie zapasowe po X dniach"} }; \ No newline at end of file diff --git a/backitup.sh b/backitup.sh index 8cde6958..b9e03b9e 100644 --- a/backitup.sh +++ b/backitup.sh @@ -65,7 +65,6 @@ MYSQL_LOESCHEN_NACH=${VAR[16]} MYSQL_HOST=${VAR[17]} MYSQL_PORT=${VAR[18]} - # Variable für optionales Weiterkopieren BKP_OK="NEIN" diff --git a/io-package.json b/io-package.json index ddf08672..15c4f7be 100644 --- a/io-package.json +++ b/io-package.json @@ -1,20 +1,31 @@ { "common": { "name": "backitup", - "version": "0.1.8", + "version": "0.2.0", "news": { - "0.1.8": { - "en": "Changes to history log, MySQL, telegram", - "de": "Änderungen an History-Log, MySQL, Telegram", - "ru": "Изменения в журнал истории, MySQL, телеграмма", - "pt": "Mudanças no histórico, MySQL, telegrama", - "nl": "Wijzigingen in historielogboek, MySQL, telegram", - "fr": "Changements au journal d'historique, MySQL, télégramme", - "it": "Modifiche al registro cronologia, MySQL, telegramma", - "es": "Cambios en el registro de historial, MySQL, telegrama", - "pl": "Zmiany w logach historii, MySQL, telegram" - }, - "0.1.7": { + "0.2.0": { + "en": "Code formatting", + "de": "Code-Formatierung", + "ru": "Форматирование кода", + "pt": "Formatação de código", + "nl": "Code-opmaak", + "fr": "Format de code", + "it": "Formattazione del codice", + "es": "Formato de código", + "pl": "Formatowanie kodu" + }, + "0.1.8": { + "en": "Changes to history log, MySQL, telegram", + "de": "Änderungen an History-Log, MySQL, Telegram", + "ru": "Изменения в журнал истории, MySQL, телеграмма", + "pt": "Mudanças no histórico, MySQL, telegrama", + "nl": "Wijzigingen in historielogboek, MySQL, telegram", + "fr": "Changements au journal d'historique, MySQL, télégramme", + "it": "Modifiche al registro cronologia, MySQL, telegramma", + "es": "Cambios en el registro de historial, MySQL, telegrama", + "pl": "Zmiany w logach historii, MySQL, telegram" + }, + "0.1.7": { "en": "Data points defined in io-package", "de": "Datenpunkte in io-package definiert", "ru": "Точки данных, определенные в io-пакете", @@ -145,8 +156,7 @@ "readme": "https://github.com/simatec/ioBroker.backitup/blob/master/README.md", "loglevel": "info", "type": "general", - "license": "MIT", - "messagebox": false + "license": "MIT" }, "native": { "minimal_BackupState": false, diff --git a/main.js b/main.js index a160cd00..8ea5ce6d 100644 --- a/main.js +++ b/main.js @@ -3,9 +3,9 @@ 'use strict'; // you have to require the utils module and call adapter function -const utils = require(__dirname + '/lib/utils'); // Get common adapter utils -const { exec } = require('child_process'); -var schedule = require('node-schedule'); +const utils = require(__dirname + '/lib/utils'); // Get common adapter utils +const {exec} = require('child_process'); +const schedule = require('node-schedule'); // you have to call the adapter function and pass a options object // name has to be set and has to be equal to adapters folder name and main file name excluding extension @@ -28,37 +28,9 @@ adapter.on('objectChange', function (id, obj) { adapter.log.info('objectChange ' + id + ' ' + JSON.stringify(obj)); }); -/* -// Im Script unten integriert und in Verwendung -// deshalb hier auskommentiert. -adapter.on('stateChange', function (id, state) { - // Warning, state can be null if it was deleted - adapter.log.info('stateChange ' + id + ' ' + JSON.stringify(state)); - - // you can use the ack flag to detect if it is status (true) or command (false) - if (state && !state.ack) { - adapter.log.info('ack is not set!'); - } -}); -*/ -// Some message was sent to adapter instance over message box. Used by email, pushover, text2speech, ... -adapter.on('message', function (obj) { - if (typeof obj === 'object' && obj.message) { - if (obj.command === 'send') { - // e.g. send email or pushover or whatever - console.log('send command'); - - // Send response in callback if required - if (obj.callback) adapter.sendTo(obj.from, obj.command, 'Message received', obj.callback); - } - } -}); - // is called when databases are connected and adapter received configuration. // start here! -adapter.on('ready', function () { - main(); -}); +adapter.on('ready', main); function main() { @@ -67,27 +39,26 @@ function main() { // ----------------------------------------------------------------------------- // allgemeine Variablen // ----------------------------------------------------------------------------- -const logging = adapter.config.state_log; // Logging on/off -const debugging = adapter.config.state_debug; // Detailiertere Loggings + const logging = adapter.config.state_log; // Logging on/off + const debugging = adapter.config.state_debug; // Detailiertere Loggings -const bash_script = 'bash /opt/iobroker/node_modules/iobroker.backitup/backitup.sh '; // Pfad zu backup.sh Datei + const bash_script = 'bash /opt/iobroker/node_modules/iobroker.backitup/backitup.sh '; // Pfad zu backup.sh Datei -const anzahl_eintraege_history = adapter.config.history_status; // Anzahl der Einträge in der History + const anzahl_eintraege_history = adapter.config.history_status; // Anzahl der Einträge in der History -let Backup = []; // Array für die Definition der Backuptypen und deren Details + let Backup = []; // Array für die Definition der Backuptypen und deren Details -// Konfigurationen für das Standard-IoBroker Backup + // Konfigurationen für das Standard-IoBroker Backup Backup[0] = []; Backup[0][0] = 'minimal'; // Backup Typ (nicht verändern!) Backup[0][1] = adapter.config.minimal_NamensZusatz; // Names Zusatz, wird an den Dateinamen angehängt Backup[0][2] = adapter.config.minimal_BackupLoeschenNach; // Alte Backups löschen nach X Tagen Backup[0][3] = adapter.config.FtpHost; // FTP-Host - if(adapter.config.nas_var === true) { // genaue Verzeichnissangabe bspw. /volume1/Backup/ auf FTP-Server - Backup[0][4] = adapter.config.FtpDir_minimal; - } - else { - Backup[0][4] = adapter.config.FtpDir; - } + if (adapter.config.nas_var === true) { // genaue Verzeichnissangabe bspw. /volume1/Backup/ auf FTP-Server + Backup[0][4] = adapter.config.FtpDir_minimal; + } else { + Backup[0][4] = adapter.config.FtpDir; + } Backup[0][5] = adapter.config.FtpUser; // Username für FTP Server - Verbindung Backup[0][6] = adapter.config.FtpPw; // Passwort für FTP Server - Verbindung Backup[0][7] = ''; // Nicht benötigt bei diesem BKP-Typ (nicht verändern!) @@ -105,12 +76,11 @@ let Backup = []; // Array für di Backup[1][1] = adapter.config.komplett_NamensZusatz; // Names Zusatz, wird an den Dateinamen angehängt Backup[1][2] = adapter.config.komplett_BackupLoeschenNach; // Alte Backups löschen nach X Tagen Backup[1][3] = adapter.config.FtpHost; // FTP-Host - if(adapter.config.nas_var === true) { // genaue Verzeichnissangabe bspw. /volume1/Backup/ auf FTP-Server - Backup[1][4] = adapter.config.FtpDir_komplett; - } - else { - Backup[1][4] = adapter.config.FtpDir; - } + if (adapter.config.nas_var === true) { // genaue Verzeichnissangabe bspw. /volume1/Backup/ auf FTP-Server + Backup[1][4] = adapter.config.FtpDir_komplett; + } else { + Backup[1][4] = adapter.config.FtpDir; + } Backup[1][5] = adapter.config.FtpUser; // Username für FTP Server - Verbindung Backup[1][6] = adapter.config.FtpPw; // Passwort für FTP Server - Verbindung Backup[1][7] = ''; // Nicht benötigt bei diesem BKP-Typ (nicht verändern!) @@ -127,12 +97,11 @@ let Backup = []; // Array für di Backup[2][1] = ''; // Nicht benötigt bei diesem BKP-Typ (nicht verändern!) Backup[2][2] = adapter.config.ccu_BackupLoeschenNach; // Alte Backups löschen nach X Tagen Backup[2][3] = adapter.config.FtpHost; // FTP-Host - if(adapter.config.nas_var === true) { // genaue Verzeichnissangabe bspw. /volume1/Backup/ auf FTP-Server - Backup[2][4] = adapter.config.FtpDir_ccu; - } - else { - Backup[2][4] = adapter.config.FtpDir; - } + if (adapter.config.nas_var === true) { // genaue Verzeichnissangabe bspw. /volume1/Backup/ auf FTP-Server + Backup[2][4] = adapter.config.FtpDir_ccu; + } else { + Backup[2][4] = adapter.config.FtpDir; + } Backup[2][5] = adapter.config.FtpUser; // Username für FTP Server - Verbindung Backup[2][6] = adapter.config.FtpPw; // Passwort für FTP Server - Verbindung Backup[2][7] = adapter.config.ccuCcuIp; // IP-Adresse der CCU @@ -142,50 +111,61 @@ let Backup = []; // Array für di Backup[2][11] = ''; // Nicht benötigt bei diesem BKP-Typ (nicht verändern!) Backup[2][12] = ''; // Nicht benötigt bei diesem BKP-Typ (nicht verändern!) -const Mysql_DBname = adapter.config.MysqlDbName; // Name der Datenbank -const Mysql_User = adapter.config.MysqlDbUser; // Benutzername für Datenbank -const Mysql_PW = adapter.config.MysqlDbPw; // Passwort für Datenbank -const Mysql_LN = adapter.config.MysqlBackupLoeschenNach; // DB-Backup löschen nach X Tagen -const Mysql_Host = adapter.config.MysqlDbHost; // Hostname der Datenbank -const Mysql_Port = adapter.config.MysqlDbPort; // Port der Datenbank + const Mysql_DBname = adapter.config.MysqlDbName; // Name der Datenbank + const Mysql_User = adapter.config.MysqlDbUser; // Benutzername für Datenbank + const Mysql_PW = adapter.config.MysqlDbPw; // Passwort für Datenbank + const Mysql_LN = adapter.config.MysqlBackupLoeschenNach; // DB-Backup löschen nach X Tagen + const Mysql_Host = adapter.config.MysqlDbHost; // Hostname der Datenbank + const Mysql_Port = adapter.config.MysqlDbPort; // Port der Datenbank -let BkpZeit_Schedule = []; // Array für die Backup Zeiten + let BkpZeit_Schedule = []; // Array für die Backup Zeiten -let Enum_ids =[]; // Array für die ID's die später in der enum.function erstellt werden + // let Enum_ids = []; // Array für die ID's die später in der enum.function erstellt werden -let history_array = []; // Array für das anlegen der Backup-Historie + let history_array = []; // Array für das anlegen der Backup-Historie // ============================================================================= // Objekte // ============================================================================= // Leere Datenpunkte mit Standardwerten befüllen. -adapter.getState('History.Backup_history', function (err, state) { - if(state ===null || state.val===null) { - adapter.setState('History.Backup_history', { val: 'Noch keine Backups erstellt', ack: true });} -}); -adapter.getState('History.letztes_minimal_Backup', function (err, state) { - if(state ===null || state.val===null) { - adapter.setState('History.letztes_minimal_Backup', { val: 'Noch keine Backups erstellt', ack: true });} -}); -adapter.getState('History.letztes_komplett_Backup', function (err, state) { - if(state ===null || state.val===null) { - adapter.setState('History.letztes_komplett_Backup', { val: 'Noch keine Backups erstellt', ack: true });} -}); -adapter.getState('History.letztes_ccu_Backup', function (err, state) { - if(state ===null || state.val===null) { - adapter.setState('History.letztes_ccu_Backup', { val: 'Noch keine Backups erstellt', ack: true });} -}); -adapter.getState('OneClick.start_minimal_Backup', function (err, state) { - if(state ===null || state.val===null) {adapter.setState('OneClick.start_minimal_Backup', { val:false, ack: true });} -}); -adapter.getState('OneClick.start_komplett_Backup', function (err, state) { - if(state ===null || state.val===null) { - adapter.setState('OneClick.start_komplett_Backup', { val:false, ack: true });} -}); -adapter.getState('OneClick.start_ccu_Backup', function (err, state) { - if(state ===null || state.val===null) { - adapter.setState('OneClick.start_ccu_Backup', { val:false, ack: true });} -}); + adapter.getState('History.Backup_history', function (err, state) { + if (state === null || state.val === null) { + adapter.setState('History.Backup_history', { + val: 'Noch keine Backups erstellt', + ack: true + }); + } + }); + adapter.getState('History.letztes_minimal_Backup', function (err, state) { + if (state === null || state.val === null) { + adapter.setState('History.letztes_minimal_Backup', {val: 'Noch keine Backups erstellt', ack: true}); + } + }); + adapter.getState('History.letztes_komplett_Backup', function (err, state) { + if (state === null || state.val === null) { + adapter.setState('History.letztes_komplett_Backup', {val: 'Noch keine Backups erstellt', ack: true}); + } + }); + adapter.getState('History.letztes_ccu_Backup', function (err, state) { + if (state === null || state.val === null) { + adapter.setState('History.letztes_ccu_Backup', {val: 'Noch keine Backups erstellt', ack: true}); + } + }); + adapter.getState('OneClick.start_minimal_Backup', function (err, state) { + if (state === null || state.val === null) { + adapter.setState('OneClick.start_minimal_Backup', {val: false, ack: true}); + } + }); + adapter.getState('OneClick.start_komplett_Backup', function (err, state) { + if (state === null || state.val === null) { + adapter.setState('OneClick.start_komplett_Backup', {val: false, ack: true}); + } + }); + adapter.getState('OneClick.start_ccu_Backup', function (err, state) { + if (state === null || state.val === null) { + adapter.setState('OneClick.start_ccu_Backup', {val: false, ack: true}); + } + }); // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ @@ -194,150 +174,150 @@ adapter.getState('OneClick.start_ccu_Backup', function (err, state) { // ############################################################################# // # # -// # Funktion zum anlegen eines Schedules fuer Backupzeit # +// # Funktion zum anlegen eines Schedules fuer Backupzeit # // # # // ############################################################################# -function BackupStellen() { - adapter.setState('Auto_Backup', false); - Backup.forEach(function(Bkp) { - - if(adapter.config[Bkp[0]+'_BackupState'] === true) { + function backupErstellen() { + adapter.setState('Auto_Backup', false); + Backup.forEach(function (Bkp) { + if (adapter.config[Bkp[0] + '_BackupState'] === true) { + let BkpUhrZeit = (adapter.config[Bkp[0] + '_BackupZeit']).split(':'); - let BkpUhrZeit = (adapter.config[Bkp[0]+'_BackupZeit']).split(':'); + if (logging) adapter.log.info('Ein ' + Bkp[0] + ' Backup wurde um ' + adapter.config[Bkp[0] + '_BackupZeit'] + ' Uhr jeden ' + adapter.config[Bkp[0] + '_BackupTageZyklus'] + ' Tag aktiviert'); - if(logging) adapter.log.info('Ein '+Bkp[0]+' Backup wurde um '+adapter.config[Bkp[0]+'_BackupZeit']+' Uhr jeden '+adapter.config[Bkp[0]+'_BackupTageZyklus']+' Tag aktiviert'); + if (BkpZeit_Schedule[Bkp[0]]) { + schedule.clearScheduleJob(BkpZeit_Schedule[Bkp[0]]); + } - if(BkpZeit_Schedule[Bkp[0]]) schedule.clearScheduleJob(BkpZeit_Schedule[Bkp[0]]); - - BkpZeit_Schedule[Bkp[0]] = schedule.scheduleJob('10 '+BkpUhrZeit[1] + ' ' +BkpUhrZeit[0] + ' */'+adapter.config[Bkp[0]+'_BackupTageZyklus']+' * * ', function (){ - backup_erstellen(Bkp[0], Bkp[1], Bkp[2], Bkp[3], Bkp[4], Bkp[5], Bkp[6], Bkp[7], Bkp[8], Bkp[9], Bkp[10], Bkp[11], Bkp[12], Mysql_DBname, Mysql_User, Mysql_PW, Mysql_LN, Mysql_Host, Mysql_Port); + BkpZeit_Schedule[Bkp[0]] = schedule.scheduleJob('10 ' + BkpUhrZeit[1] + ' ' + BkpUhrZeit[0] + ' */' + adapter.config[Bkp[0] + '_BackupTageZyklus'] + ' * * ', function () { + backup_erstellen(Bkp[0], Bkp[1], Bkp[2], Bkp[3], Bkp[4], Bkp[5], Bkp[6], Bkp[7], Bkp[8], Bkp[9], Bkp[10], Bkp[11], Bkp[12], Mysql_DBname, Mysql_User, Mysql_PW, Mysql_LN, Mysql_Host, Mysql_Port); }); - if(debugging) adapter.log.info('10 '+BkpUhrZeit[1] + ' ' + BkpUhrZeit[0] + ' */'+adapter.config[Bkp[0]+'_BackupTageZyklus']+' * * '); - } - else { - if(logging) adapter.log.info ('Das '+Bkp[0]+' Backup wurde deaktiviert'); + if (debugging) adapter.log.info('10 ' + BkpUhrZeit[1] + ' ' + BkpUhrZeit[0] + ' */' + adapter.config[Bkp[0] + '_BackupTageZyklus'] + ' * * '); + } else { + if (logging) adapter.log.info('Das ' + Bkp[0] + ' Backup wurde deaktiviert'); - if(BkpZeit_Schedule[Bkp[0]]) schedule.clearScheduleJob(BkpZeit_Schedule[Bkp[0]]); + if (BkpZeit_Schedule[Bkp[0]]) { + schedule.clearScheduleJob(BkpZeit_Schedule[Bkp[0]]); + } } - }); -} + }); + } // ############################################################################# // # # // # Funktion zum Ausführen des Backups mit obigen Einstellungen # // # # // ############################################################################# -function backup_erstellen(typ, name, zeit, host, pfad, user, passwd, ccuip, ccuusr, ccupw, cifsmnt, bkpiors, redisst, mysqldb, mysqlusr, mysqlpw, mysqlln, mysqlhost, mysqlport) { - - if(debugging) adapter.log.info(bash_script+'"'+typ+'|'+name+'|'+zeit+'|'+host+'|'+pfad+'|'+user+'|'+passwd+'|'+ccuip+'|'+ccuusr+'|'+ccupw+'|'+cifsmnt+'|'+bkpiors+'|'+redisst+'|'+mysqldb+'|'+mysqlusr+'|'+mysqlpw+'|'+mysqlln+'|'+mysqlhost+'|'+mysqlport+'"'); + function backup_erstellen(typ, name, zeit, host, pfad, user, passwd, ccuip, ccuusr, ccupw, cifsmnt, bkpiors, redisst, mysqldb, mysqlusr, mysqlpw, mysqlln, mysqlhost, mysqlport) { - // Telegram Message versenden - if(debugging){ - if(adapter.config.Telegram_instanz !== ''){ - adapter.log.info('Gewaehlte Telegram-Instanz: ' + adapter.config.Telegram_instanz); + if (debugging) { + adapter.log.info(bash_script + '"' + typ + '|' + name + '|' + zeit + '|' + host + '|' + pfad + '|' + user + '|' + passwd + '|' + ccuip + '|' + ccuusr + '|' + ccupw + '|' + cifsmnt + '|' + bkpiors + '|' + redisst + '|' + mysqldb + '|' + mysqlusr + '|' + mysqlpw + '|' + mysqlln + '|' + mysqlhost + '|' + mysqlport + '"'); } - else{ - adapter.log.info('Keine Telegram-Instanz gewaehlt!'); - } - } - - if(adapter.config.telegram_message === true && adapter.config.Telegram_instanz !== ''){ - adapter.log.info('Telegram Message ist aktiv'); - let messagetext = 'Es wurde am '+HistoryEintrag(new Date())+' ein neues '+typ+' Backup erstellt'; - if(host !== ''){ - if(cifsmnt == 'FTP') messagetext += ', und via FTP nach '+host+pfad+' kopiert/verschoben'; - if(cifsmnt == 'CIFS') messagetext += ', und unter '+host+pfad+' gespeichert'; + // Telegram Message versenden + if (debugging) { + if (adapter.config.Telegram_instanz !== '') { + adapter.log.info('Gewaehlte Telegram-Instanz: ' + adapter.config.Telegram_instanz); + } else { + adapter.log.info('Keine Telegram-Instanz gewaehlt!'); + } } - messagetext += '!'; - adapter.sendTo(adapter.config.Telegram_instanz, "send", {text: 'BackItUp:\n' + messagetext}); -// adapter.sendTo("telegram", "send", {text: (String('BackItUp:\n' + messagetext))}); - } -// hier kein new HistoryEintrag(new Date()) machen dann funktioniert das ganze nicht mehr - adapter.setState('History.letztes_'+typ+'_Backup', HistoryEintrag(new Date())); - - let ftp_bkp_u; - - new Backup_history_anlegen(typ, host, cifsmnt); - - exec((bash_script+' "'+typ+'|'+name+'|'+zeit+'|'+host+'|'+pfad+'|'+user+'|'+passwd+'|'+ccuip+'|'+ccuusr+'|'+ccupw+'|'+cifsmnt+'|'+bkpiors+'|'+redisst+'|'+mysqldb+'|'+mysqlusr+'|'+mysqlpw+'|'+mysqlln+'|'+mysqlhost+'|'+mysqlport+'"'), function(err, stdout, stderr) { - if(logging){ - if(err) adapter.log.info(stderr, 'error'); - else adapter.log.info('exec: ' + stdout); + if (adapter.config.telegram_message === true && adapter.config.Telegram_instanz !== '') { + adapter.log.info('Telegram Message ist aktiv'); + + let messagetext = 'Es wurde am ' + historyEintrag(new Date()) + ' ein neues ' + typ + ' Backup erstellt'; + if (host !== '') { + if (cifsmnt === 'FTP') { + messagetext += ', und via FTP nach ' + host + pfad + ' kopiert/verschoben'; + } else + if (cifsmnt === 'CIFS') { + messagetext += ', und unter ' + host + pfad + ' gespeichert'; + } + } + messagetext += '!'; + adapter.sendTo(adapter.config.Telegram_instanz, 'send', {text: 'BackItUp:\n' + messagetext}); +// adapter.sendTo('telegram', 'send', {text: (String('BackItUp:\n' + messagetext))}); } - }); -} -// ############################################################################# -// # # -// # Funktion zum erstellen eines Datum-Strings # -// # # -// ############################################################################# + // hier kein new historyEintrag(new Date()) machen dann funktioniert das ganze nicht mehr + adapter.setState('History.letztes_' + typ + '_Backup', historyEintrag(new Date())); -function HistoryEintrag(date) { - const MonatsNamen = [ - "Januar", "Februar", "Maerz", - "April", "Mai", "Juni", "Juli", - "August", "September", "Oktober", - "November", "Dezember" - ]; + // let ftp_bkp_u; - let Tag = date.getDate(); - let MonatsIndex = date.getMonth(); - let Jahr = date.getFullYear(); - let Stunde = date.getHours(); - let Minute = date.getMinutes(); + backupHistoryAnlegen(typ, host, cifsmnt); -// return Tag+' '+MonatsNamen[MonatsIndex]+' '+Jahr+ ' um '+Stunde+':'+Minute+' Uhr'; - return ('0' + Tag).slice(-2)+' '+MonatsNamen[MonatsIndex]+' '+Jahr+ ' um '+('0' + Stunde).slice(-2)+':'+('0' + Minute).slice(-2)+' Uhr'; + exec(bash_script + ' "' + typ + '|' + name + '|' + zeit + '|' + host + '|' + pfad + '|' + user + '|' + passwd + '|' + ccuip + '|' + ccuusr + '|' + ccupw + '|' + cifsmnt + '|' + bkpiors + '|' + redisst + '|' + mysqldb + '|' + mysqlusr + '|' + mysqlpw + '|' + mysqlln + '|' + mysqlhost + '|' + mysqlport + '"', function (err, stdout, stderr) { + if (logging) { + if (err) { + adapter.log.error(stderr); + } else { + adapter.log.info('exec: ' + stdout); + } + } + }); -} + } // ############################################################################# // # # -// # Backupdurchführung in History eintragen # +// # Funktion zum erstellen eines Datum-Strings # // # # // ############################################################################# -function Backup_history_anlegen(typ, host, cifsmnt) { - adapter.getState('History.Backup_history', function (err, state) { - let history_liste = state.val; - if(history_liste == 'Noch keine Backups erstellt') history_liste = ''; - history_array = history_liste.split(' '); - if(history_array.length >= anzahl_eintraege_history){ - history_array.splice((anzahl_eintraege_history - 1),1); - } - let zeitstempel = HistoryEintrag(new Date()); - let historytext; - if(host !== ''){ - if(cifsmnt == 'FTP') historytext = '' + zeitstempel + ' - Typ:' +typ+ ' - FTP-Sicherung: JA'; - if(cifsmnt == 'CIFS') historytext = '' + zeitstempel + ' - Typ:' +typ+ ' - CIFS-Mount: JA'; - } - else{ - historytext = '' + zeitstempel + ' - Typ:' +typ+ ' - Nur lokal gesichert'; - } - history_array.unshift(historytext); + function historyEintrag(date) { + const MonatsNamen = [ + 'Januar', 'Februar', 'Maerz', + 'April', 'Mai', 'Juni', 'Juli', + 'August', 'September', 'Oktober', + 'November', 'Dezember' + ]; - adapter.setState('History.Backup_history', history_array.join(' ')); - }); + let Tag = date.getDate(); + let MonatsIndex = date.getMonth(); + let Jahr = date.getFullYear(); + let Stunde = date.getHours(); + let Minute = date.getMinutes(); -} + // return Tag+' '+MonatsNamen[MonatsIndex]+' '+Jahr+ ' um '+Stunde+':'+Minute+' Uhr'; + return ('0' + Tag).slice(-2) + ' ' + MonatsNamen[MonatsIndex] + ' ' + Jahr + ' um ' + ('0' + Stunde).slice(-2) + ':' + ('0' + Minute).slice(-2) + ' Uhr'; + } // ############################################################################# // # # -// # Ablaeufe nach Neustart des Backupscripts # +// # Backupdurchführung in History eintragen # // # # // ############################################################################# -function ScriptStart() { - - new BackupStellen(); + function backupHistoryAnlegen(typ, host, cifsmnt) { + adapter.getState('History.Backup_history', function (err, state) { + let history_liste = state.val; + if (history_liste === 'Noch keine Backups erstellt') history_liste = ''; + history_array = history_liste.split(' '); + if (history_array.length >= anzahl_eintraege_history) { + history_array.splice((anzahl_eintraege_history - 1), 1); + } + let zeitstempel = historyEintrag(new Date()); + let historytext; + if (host !== '') { + if (cifsmnt === 'FTP') { + historytext = '' + zeitstempel + ' - Typ:' + typ + ' - FTP-Sicherung: JA'; + } else + if (cifsmnt === 'CIFS') { + historytext = '' + zeitstempel + ' - Typ:' + typ + ' - CIFS-Mount: JA'; + } + } else { + historytext = '' + zeitstempel + ' - Typ:' + typ + ' - Nur lokal gesichert'; + } + history_array.unshift(historytext); -} + adapter.setState('History.Backup_history', history_array.join(' ')); + }); + } + // ############################################################################# // # # @@ -346,41 +326,40 @@ function ScriptStart() { // # # // ############################################################################# -adapter.subscribeStates('OneClick*'); // subscribe on all variables of this adapter instance with pattern "adapterName.X.memory*" - -// Wird ausgefürt wenn sich ein State ändert -adapter.on('stateChange', function (id, state) { + adapter.subscribeStates('OneClick*'); // subscribe on all variables of this adapter instance with pattern "adapterName.X.memory*" - if (id == adapter.name+'.'+adapter.instance+'.OneClick.start_minimal_Backup' && state.val === true ){ - adapter.log.info('OneClick Minimal Backup gestartet'); - backup_erstellen(Backup[0][0], Backup[0][1], Backup[0][2], Backup[0][3], Backup[0][4], Backup[0][5], Backup[0][6], Backup[0][7], Backup[0][8], Backup[0][9], Backup[0][10], Backup[0][11], Backup[0][12], Mysql_DBname, Mysql_User, Mysql_PW, Mysql_LN, Mysql_Host, Mysql_Port); - if(debugging)adapter.log.info('backup_erstellen('+Backup[0][0]+','+Backup[0][1]+','+Backup[0][2]+','+Backup[0][3]+','+Backup[0][4]+','+Backup[0][5]+','+Backup[0][6]+','+Backup[0][7]+','+Backup[0][8]+','+Backup[0][9]+','+Backup[0][10]+','+Backup[0][11]+','+Backup[0][12]+','+Mysql_DBname+','+Mysql_User+','+Mysql_PW+','+Mysql_LN+','+Mysql_Host+','+Mysql_Port+')'); - setTimeout(function(){ adapter.setState('OneClick.start_minimal_Backup', false, true); }, 20000); - } - if (id == adapter.name+'.'+adapter.instance+'.OneClick.start_komplett_Backup' && state.val === true ){ - adapter.log.info('OneClick Komplett Backup gestartet'); - backup_erstellen(Backup[1][0], Backup[1][1], Backup[1][2], Backup[1][3], Backup[1][4], Backup[1][5], Backup[1][6], Backup[1][7], Backup[1][8], Backup[1][9], Backup[1][10], Backup[1][11], Backup[1][12], Mysql_DBname, Mysql_User, Mysql_PW, Mysql_LN, Mysql_Host, Mysql_Port); - if(debugging)adapter.log.info('backup_erstellen('+Backup[1][0]+','+Backup[1][1]+','+Backup[1][2]+','+Backup[1][3]+','+Backup[1][4]+','+Backup[1][5]+','+Backup[1][6]+','+Backup[1][7]+','+Backup[1][8]+','+Backup[1][9]+','+Backup[1][10]+','+Backup[1][11]+','+Backup[1][12]+','+Mysql_DBname+','+Mysql_User+','+Mysql_PW+','+Mysql_LN+','+Mysql_Host+','+Mysql_Port+')'); - setTimeout(function(){ adapter.setState('OneClick.start_komplett_Backup', false, true); }, 5000); - } - if (id == adapter.name+'.'+adapter.instance+'.OneClick.start_ccu_Backup' && state.val === true ){ - adapter.log.info('OneClick CCU Backup gestartet'); - backup_erstellen(Backup[2][0], Backup[2][1], Backup[2][2], Backup[2][3], Backup[2][4], Backup[2][5], Backup[2][6], Backup[2][7], Backup[2][8], Backup[2][9], Backup[2][10], Backup[2][11], Backup[2][12], Mysql_DBname, Mysql_User, Mysql_PW, Mysql_LN, Mysql_Host, Mysql_Port); - if(debugging)adapter.log.info('backup_erstellen('+Backup[2][0]+','+Backup[2][1]+','+Backup[2][2]+','+Backup[2][3]+','+Backup[2][4]+','+Backup[2][5]+','+Backup[2][6]+','+Backup[2][7]+','+Backup[2][8]+','+Backup[2][9]+','+Backup[2][10]+','+Backup[2][11]+','+Backup[2][12]+','+Mysql_DBname+','+Mysql_User+','+Mysql_PW+','+Mysql_LN+','+Mysql_Host+','+Mysql_Port+')'); - setTimeout(function(){ adapter.setState('OneClick.start_ccu_Backup', false, true); }, 20000); - } - -}); - -ScriptStart(); + // Wird ausgefürt wenn sich ein State ändert + adapter.on('stateChange', function (id, state) { + if (id === adapter.name + '.' + adapter.instance + '.OneClick.start_minimal_Backup' && state.val === true) { + adapter.log.info('OneClick Minimal Backup gestartet'); + backup_erstellen(Backup[0][0], Backup[0][1], Backup[0][2], Backup[0][3], Backup[0][4], Backup[0][5], Backup[0][6], Backup[0][7], Backup[0][8], Backup[0][9], Backup[0][10], Backup[0][11], Backup[0][12], Mysql_DBname, Mysql_User, Mysql_PW, Mysql_LN, Mysql_Host, Mysql_Port); + if (debugging) { + adapter.log.info('backup_erstellen(' + Backup[0][0] + ',' + Backup[0][1] + ',' + Backup[0][2] + ',' + Backup[0][3] + ',' + Backup[0][4] + ',' + Backup[0][5] + ',' + Backup[0][6] + ',' + Backup[0][7] + ',' + Backup[0][8] + ',' + Backup[0][9] + ',' + Backup[0][10] + ',' + Backup[0][11] + ',' + Backup[0][12] + ',' + Mysql_DBname + ',' + Mysql_User + ',' + Mysql_PW + ',' + Mysql_LN + ',' + Mysql_Host + ',' + Mysql_Port + ')'); + } + setTimeout(function () { + adapter.setState('OneClick.start_minimal_Backup', false, true); + }, 20000); + } + if (id === adapter.name + '.' + adapter.instance + '.OneClick.start_komplett_Backup' && state.val === true) { + adapter.log.info('OneClick Komplett Backup gestartet'); + backup_erstellen(Backup[1][0], Backup[1][1], Backup[1][2], Backup[1][3], Backup[1][4], Backup[1][5], Backup[1][6], Backup[1][7], Backup[1][8], Backup[1][9], Backup[1][10], Backup[1][11], Backup[1][12], Mysql_DBname, Mysql_User, Mysql_PW, Mysql_LN, Mysql_Host, Mysql_Port); + if (debugging) adapter.log.info('backup_erstellen(' + Backup[1][0] + ',' + Backup[1][1] + ',' + Backup[1][2] + ',' + Backup[1][3] + ',' + Backup[1][4] + ',' + Backup[1][5] + ',' + Backup[1][6] + ',' + Backup[1][7] + ',' + Backup[1][8] + ',' + Backup[1][9] + ',' + Backup[1][10] + ',' + Backup[1][11] + ',' + Backup[1][12] + ',' + Mysql_DBname + ',' + Mysql_User + ',' + Mysql_PW + ',' + Mysql_LN + ',' + Mysql_Host + ',' + Mysql_Port + ')'); + setTimeout(function () { + adapter.setState('OneClick.start_komplett_Backup', false, true); + }, 5000); + } + if (id === adapter.name + '.' + adapter.instance + '.OneClick.start_ccu_Backup' && state.val === true) { + adapter.log.info('OneClick CCU Backup gestartet'); + backup_erstellen(Backup[2][0], Backup[2][1], Backup[2][2], Backup[2][3], Backup[2][4], Backup[2][5], Backup[2][6], Backup[2][7], Backup[2][8], Backup[2][9], Backup[2][10], Backup[2][11], Backup[2][12], Mysql_DBname, Mysql_User, Mysql_PW, Mysql_LN, Mysql_Host, Mysql_Port); + if (debugging) adapter.log.info('backup_erstellen(' + Backup[2][0] + ',' + Backup[2][1] + ',' + Backup[2][2] + ',' + Backup[2][3] + ',' + Backup[2][4] + ',' + Backup[2][5] + ',' + Backup[2][6] + ',' + Backup[2][7] + ',' + Backup[2][8] + ',' + Backup[2][9] + ',' + Backup[2][10] + ',' + Backup[2][11] + ',' + Backup[2][12] + ',' + Mysql_DBname + ',' + Mysql_User + ',' + Mysql_PW + ',' + Mysql_LN + ',' + Mysql_Host + ',' + Mysql_Port + ')'); + setTimeout(function () { + adapter.setState('OneClick.start_ccu_Backup', false, true); + }, 20000); + } -// ############## Ende backitup ######################### -/* - adapter.checkGroup('admin', 'admin', function (res) { - console.log('check group user admin group admin: ' + res); }); -*/ - + backupErstellen(); +// ############## Ende backitup ######################### } diff --git a/package.json b/package.json index 7e964052..4fb6562d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iobroker.backitup", - "version": "0.1.8", + "version": "0.2.0", "engines": { "node": ">=6.0.0" }, @@ -28,17 +28,17 @@ "home automation", "Backup" ], + "os": ["!win32"], "repository": { "type": "git", "url": "https://github.com/simatec/ioBroker.backitup" }, "dependencies": { - "node-schedule": "^1.3.0", - "child_process": "^1.0.2" + "node-schedule": "^1.3.0" }, "devDependencies": { "gulp": "^3.9.1", - "mocha": "^4.1.0", + "mocha": "^5.2.0", "chai": "^4.1.2" }, "main": "main.js", From c9d52d798761d0b06e3a9bd802c3cbf487805661 Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Sat, 14 Jul 2018 19:33:42 +0200 Subject: [PATCH 2/3] (bluefox) move documentation to one place --- README.md | 170 +--------------------------- docs/de/backitup.md | 31 +----- docs/en/backitup.md | 266 +++++++++++++++++++++----------------------- 3 files changed, 136 insertions(+), 331 deletions(-) diff --git a/README.md b/README.md index b0194e52..abb9c0f6 100644 --- a/README.md +++ b/README.md @@ -7,174 +7,8 @@ [![NPM](https://nodei.co/npm/iobroker.backitup.png?downloads=true)](https://nodei.co/npm/iobroker.backitup/) -***English Description: https://github.com/simatec/ioBroker.backitup/blob/master/README_english.md*** - -Backitup ist eine Backuplösung, mit der das zyklische Sichern einer IoBroker-Installation sowie einer Homematic CCU möglich ist. - -In der aktuellen Version funktioniert der Adapter nur auf Linux, da die fehlerfreie Ausführung des Shell-Scripts auf anderen Distributionen NOCH nicht funktioniert. - -## Inhaltsverzeichnis: -1. Backup Type - - 1.1 Minimales Backup (Standard IoBroker Backup) - - 1.2 Komplettes Backup - - 1.3 CCU Backup (CCU-Original / pivCCU / Raspberrymatic) - - 1.4 Optionales Mysql-Backup (Localhost) - -2. Vorbereitung - -3. Ftp vs. CIFS - -4. Verwendung - - 4.1 Erstellte Datenpunkte - - 4.3 History-Log mit CCS formatieren - - 4.4 Backupstatus im OneClick-Button darstellen -5. Restore eines Backups - - 5.1 Minimal Backup wiederherstellen - - 5.2 Komplett Backup wiederherstellen - - 5.3 Raspberrymatic/CCU Backup wiederherstellen -6. Fehlersuche - - 6.1 Logging aktivieren - - 6.2 Debugging aktivieren -7. Aufgetretene Fehler / Lösungen - - 7.1 Webinterface nach Restore nicht erreichbar - - 7.2 JS-Datenbunkt nicht beschreibbar - - 7.3 Fehlermeldung: "Komando nicht gefunden" - - 7.4 Komplett-Backup bleibt hängen - - 7.5 Geänderte Werte in Dp werden nicht übernommen -8. Changelog - - -## 1. Backuptypen: - -Backitup bietet die Möglichkeit drei (optional mit DB-Backup) verschiedene Backuptypen zyklisch oder auf Knopfdruck durch zu führen. Jedes Backup wird standardmäßig im Verzeichnis /opt/iobroker/backups/ abgelegt. Optional kann ein FTP-Upload eingerichtet oder alternativ ein CIFS-Mount genutzt werden. - -1. Standard Backup - - Dieses Backup entspricht dem in IoBroker enthaltenen Backup welches man in der Konsole über den Aufruf „./iobroker backup“ starten kann. Nur wird es hier durch die festgelegten Einstellungen in der Adapterkonfiguration oder dem Widget OneClick-Backup durchgeführt ohne die Konsole verwenden zu müssen. -2. Komplettes Backup - - Dieses Backup sichert den kompletten IoBroker Ordner inklusive aller Unterordner und deren Dateien samt Dateiberechtigungen. Hierbei sollte die Dateigröße nicht ausser Acht gelassen werden, denn ein solches Backup hat oft mehrere hundert MB. -Um sicher zu gehen dass alle aktuellsten States gesichert werden muss hier in der Konfiguration der Hacken bei IoBroker Stop/Start gesetzt werden. -3. CCU Backup (Homematic) - - Dieses Backup bietet die Möglichkeit 3 verschiedene Varianten einer Homematic Installations (CCU-Original / pivCCU / Raspberrymatic) zu sichern. Auch die Ausführung dieses Backups kann durch die festgelegten Einstellungen in der Adapterkonfiguration oder dem Widget OneClick-Backup durchgeführt werden. -4. Mysql-Backup (Localhost) - - Dieses separat einstellbare Backup wird sofern es aktiviert ist, bei jedem Backup egal ob „minimal“ oder „komplett“ erstellt und nach Ablauf der angegebenen Vorhaltezeit auch gelöscht. FTP oder CIFS sind für dieses Backup ebenfalls gültig sofern bei den anderen IoBroker-Backup-Typen eingestellt. - -## 2. Vorbereitung: - -Folgende Schritte sollten durchgeführt werden um den Adapter verwenden zu können (wenn das Backup-Script v1/v2/v3 verwendet wurde, zuerst Alles löschen (Datenpunkte/Enum.functions/Shell-Script und JavaScript deaktivieren oder löschen!) - - -## 3. Ftp-Dienst oder CIFS für das optionale weitersichern auf einen Nas nutzen? - - - Vorteile CIFS: - - weniger Schreibzyklen auf euren Datenträger (evtl. relevant wenn Raspberry mit SD-Karte verwendet wird um Diese zu schonen) - - Es ist möglich die „Alten Backups“ automatisiert auf dem Nas löschen zu lassen - - Nachteile CIFS: - - Wenn ein Mounten nicht möglich ist, wird kein Backup erstellt! - - „Alte Backups“ können automatisiert auf dem Nas gelöscht werden. Im schlimmsten Fall ist somit kein Backup mehr vorhanden wenn ihr es benötigt. - - Pfadangaben (Schreibweise beachten): - - CIFS: "Freigabename/Pfadangabe" - - FTP: "/Pfadangabe" - - -## 4. Verwendung: - -1. Der Adapter erstellt 7 Datenpunkte zur Verwendung in Vis - - start_ccu_Backup -> dient als Auslösetrigger für ein CCU-Backup (Kann in Vis durch einen Button auf true gesetzt werden) - - start_minimal_Backup -> dient als Auslösetrigger für ein Standard-Backup (Kann in Vis durch einen Button auf true gesetzt werden) - - start_komplett_Backup -> dient als Auslösetrigger für ein Komplett-Backup (Kann in Vis durch einen Button auf true gesetzt werden) - - - Backup_history -> diehnt als History-Log welcher in Vis via CCS vom Design anpassbar ist. - - letztes_ccu_Backup -> speichert das Erstell-Datum und die Uhrzeit des letzten CCU Backups - - letztes_minimal_Backup -> speichert das Erstell-Datum und die Uhrzeit des letzten Standard Backups - - letztes_ccu_Backup -> speichert das Erstell-Datum und die Uhrzeit des letzten Komplett Backups - -2. History-Log in Vis anzeigen - - Es ist möglich den History-Log bspw. in einem Html-Widget durch eintragen folgender Zeile in HTML darzustellen: -``` -{backitup.0.History.Backup_history} -``` -Syntax: {BackitupInstanz.History.Backup_history} - - -3. CCS-Formatierung des History-Logs: - ``` - .backup_history{ - display:block; - width:100%; - /* overflow-y:scroll; */ - } - .bkptyp_minimal - { - float:left; - color:white; - font-size:18px; - } - .bkptyp_komplett - { - float:left; - color:yellow; - font-size:18px; - } - .bkptyp_ccu - { - float:left; - color:red; - font-size:18px; - } - ``` -4. OneClick-Button mit Status-Text - - Wenn ein OneClick-Datenpunkt auf true gesetzt wird startet das entsprechende Backup und nach einer vordefinierten Zeit wird dieser Datenpunkt wieder auf false gesetzt somit ist es möglich einen Button mit Status zu erstellen, hierzu folgende Zeile anpassen und in Vis als Knopftext eintragen: -``` -{wert:backitup.0.OneClick.start_minimal_Backup; wert === "true" ? "Minimal Backup
wird erstellt" : "Minimal Backup
starten"} - -``` -Syntax: {wert:BackitupInstanz.OnClick.Auslösetrigger; wert === "true" ? "Text während der Backuperstellung" : "Standard-Text"} - -## 5. Restore: - -1. Restore eines minimalen / normalen IoBroker Backups: - - Das Backup muss wie gewohnt im Verzeichnis „opt/iobroker/backups/“ liegen - - Es kann über die Konsole mit Hilfe des Befehls: „iobroker restore (Nummer des Backups aus der Liste)“ wieder hergestellt werden. - -2. Restore eines kompletten Backups: - - Den Befehl:“sudo iobroker stop“ über die Konsole ausführen - - Das erstellte Backup muss in das Verzeichnis „root/“ kopiert werden - - Den Befehl:" sudo tar -xzvf Backupname.tar.gz -C / " über die Konsole ausführen - - Warten - Während der Wiederherstellung wird euch angezeigt was gerade gemacht wird - - Den Befehl: „sudo iobroker start“ über die Konsole ausführen - -3. Restore eines Raspberrymatic / CCU Backups: - - *.sbk Datei via SCP in das Verzeichnis „ /usr/local/tmp directory“ auf die Raspberrymatic kopieren - - Über die Konsole als Root-User auf der Raspberrymatic einloggen - - Den Befehl: „/bin/restoreBackup.sh /user/local/tmp/EuerBackupDateiname“ auf der Raspberrymatic ausführen. - - Den Befehl:“reboot“ auf der Raspberrymatic ausführen um den PI neu zu starten - -Alternativ kann das Backup natürlich auch wie gewohnt über das Webinterface wieder hergestellt werden. - -## 6. Fehlersuche: - -1. In der Adapterkonfiguration gibt es die Möglichkeit Log zu aktivieren so werden im IoBroker-Log verschiedene Meldungen (bspw. Backup-Zeiten und States) die zur Fehlersuche dienen können aufgelistet - -2. Zusätzlich gibt es die Möglichkeit Debug zu aktivieren nun wird im IoBroker-Log der Befehl ausgegeben der an die backitup.sh übergeben wird. Dieser Befehl kann eins zu eins in die Konsole (mit Putty o.ä) eingegeben werden um Fehler eingrenzen zu können. - -## 7. Aufgetretene Fehler / Lösungen: - -Hier eine Liste der bisher aufgetretenen Probleme und deren Lösungen sofern vorhanden. - -1. Olifall (aus dem Forum) hatte das Problem dass nach dem Restore das Webinterface des IoBrokers nicht mehr erreichbar war, durch folgende Schritte über die Konsole konnte er dies beheben: - - sudo iobroker status - - Meldung = "No connection to states 127.0.0.0:6379[redis]" - - sudo apt-get install redis-server - -2. Beim Testen kam es bei Anderen vor dass einige Datenpunkte nicht beschreib /-änderbar waren, dieser Fehler konnte nicht nachgestellt und dementsprechend nicht behoben werden. - -3. Fehlermeldung: „Kommando nicht gefunden“ -Durch die Unterschiede von Unix und Windows, darf die backitup.sh nicht unter Windows (Editor) geändert werden. -Erklärung: -Unter DOS wird in Textdateien ein Zeilenende durch die Sequenz return (Dezimalcode 13) und new line (Dezimalcode 10) dargestellt. Unix verwendet dagegen nur new line. - -4. Iobroker bleibt beim komplett-Backup hängen / startet nicht mehr -Einige Benutzer berichteten dass das IoBroker komplett-Backup nicht richtig durchläuft bzw. der IoBroker gestoppt und nicht mehr gestartet wird. Hierfür ist es möglich in der Adapter- Konfigurations-Datenpunkten den Stop/Start des IoBrokers beim komplett-Backup zu deaktivieren. +***[English Description](docs/en/backitup.md)*** +***[Deutsche Beschreibung](docs/de/backitup.md)*** ## Changelog ### 0.2.0 (14.07.2018) diff --git a/docs/de/backitup.md b/docs/de/backitup.md index 7a79800b..da902485 100644 --- a/docs/de/backitup.md +++ b/docs/de/backitup.md @@ -1,14 +1,7 @@ -![Logo](img/backitup.png) -# ioBroker.backitup -================= - -[![NPM version](http://img.shields.io/npm/v/iobroker.backitup.svg)](https://www.npmjs.com/package/iobroker.backitup) -[![Downloads](https://img.shields.io/npm/dm/iobroker.backitup.svg)](https://www.npmjs.com/package/iobroker.backitup) - -[![NPM](https://nodei.co/npm/iobroker.backitup.png?downloads=true)](https://nodei.co/npm/iobroker.backitup/) - Backitup ist eine Backuplösung, mit der das zyklische Sichern einer IoBroker-Installation sowie einer Homematic CCU möglich ist. +In der aktuellen Version funktioniert der Adapter nur auf Linux, da die fehlerfreie Ausführung des Shell-Scripts auf anderen Distributionen NOCH nicht funktioniert. + ## Inhaltsverzeichnis: 1. Backup Type - 1.1 Minimales Backup (Standard IoBroker Backup) @@ -16,6 +9,8 @@ Backitup ist eine Backuplösung, mit der das zyklische Sichern einer IoBroker-In - 1.3 CCU Backup (CCU-Original / pivCCU / Raspberrymatic) - 1.4 Optionales Mysql-Backup (Localhost) +2. Vorbereitung + 3. Ftp vs. CIFS 4. Verwendung @@ -62,7 +57,6 @@ Folgende Schritte sollten durchgeführt werden um den Adapter verwenden zu könn - Vorteile CIFS: - weniger Schreibzyklen auf euren Datenträger (evtl. relevant wenn Raspberry mit SD-Karte verwendet wird um Diese zu schonen) - Es ist möglich die „Alten Backups“ automatisiert auf dem Nas löschen zu lassen - - Keine Notwendigkeit des lftp-Service da euer Nas direkt eingehängt ist. - Nachteile CIFS: - Wenn ein Mounten nicht möglich ist, wird kein Backup erstellt! - „Alte Backups“ können automatisiert auf dem Nas gelöscht werden. Im schlimmsten Fall ist somit kein Backup mehr vorhanden wenn ihr es benötigt. @@ -84,7 +78,7 @@ Folgende Schritte sollten durchgeführt werden um den Adapter verwenden zu könn - letztes_ccu_Backup -> speichert das Erstell-Datum und die Uhrzeit des letzten Komplett Backups 2. History-Log in Vis anzeigen -Es ist möglich den History-Log bspw. in einem Html-Widget durch eintragen folgender Zeile in HTML darzustellen: + - Es ist möglich den History-Log bspw. in einem Html-Widget durch eintragen folgender Zeile in HTML darzustellen: ``` {backitup.0.History.Backup_history} ``` @@ -118,7 +112,7 @@ Syntax: {BackitupInstanz.History.Backup_history} } ``` 4. OneClick-Button mit Status-Text -Wenn ein OneClick-Datenpunkt auf true gesetzt wird startet das entsprechende Backup und nach einer vordefinierten Zeit wird dieser Datenpunkt wieder auf false gesetzt somit ist es möglich einen Button mit Status zu erstellen, hierzu folgende Zeile anpassen und in Vis als Knopftext eintragen: + - Wenn ein OneClick-Datenpunkt auf true gesetzt wird startet das entsprechende Backup und nach einer vordefinierten Zeit wird dieser Datenpunkt wieder auf false gesetzt somit ist es möglich einen Button mit Status zu erstellen, hierzu folgende Zeile anpassen und in Vis als Knopftext eintragen: ``` {wert:backitup.0.OneClick.start_minimal_Backup; wert === "true" ? "Minimal Backup
wird erstellt" : "Minimal Backup
starten"} @@ -171,16 +165,3 @@ Unter DOS wird in Textdateien ein Zeilenende durch die Sequenz return (Dezimalco 4. Iobroker bleibt beim komplett-Backup hängen / startet nicht mehr Einige Benutzer berichteten dass das IoBroker komplett-Backup nicht richtig durchläuft bzw. der IoBroker gestoppt und nicht mehr gestartet wird. Hierfür ist es möglich in der Adapter- Konfigurations-Datenpunkten den Stop/Start des IoBrokers beim komplett-Backup zu deaktivieren. -## 8. Changelog: - -#0.1.4 (03.07.2018) - - (simatec/peoples) diverse Anpassungen - -#0.1.3 (02.07.2018) - - (simatec/peoples) Sprachen hinzugefügt - -#0.1.2 (30.06.2018) - - (simatec/peoples) Erste Beta-Version - -#0.1.0 (25.06.2018) - - (simatec/peoples) Erste Git-Adapter-Version \ No newline at end of file diff --git a/docs/en/backitup.md b/docs/en/backitup.md index 010419b5..81e4137b 100644 --- a/docs/en/backitup.md +++ b/docs/en/backitup.md @@ -1,182 +1,172 @@ -![Logo](img/backitup.png) -# ioBroker.backitup -================= +***Translation by https://www.deepl.com/translator*** -[![NPM version](http://img.shields.io/npm/v/iobroker.backitup.svg)](https://www.npmjs.com/package/iobroker.backitup) -[![Downloads](https://img.shields.io/npm/dm/iobroker.backitup.svg)](https://www.npmjs.com/package/iobroker.backitup) +Backitup is a backup solution that allows cyclical backup of an IoBroker installation and a Homematic CCU. -[![NPM](https://nodei.co/npm/iobroker.backitup.png?downloads=true)](https://nodei.co/npm/iobroker.backitup/) +In the current version the adapter only works on Linux, because the error-free execution of the shell script does NOT work on other distributions. -Backitup is a backup solution that allows the system to securely host an IoBroker installation and a Homematic CCU. +## Table of contents: +1st backup type + - 1.1 Minimum Backup (Standard IoBroker Backup) + - 1.2 Full backup + - 1.3 CCU Backup (original CCU / pivCCU / Raspberrymatic) + - 1.4 Optional mysql backup (local host) -## Table of Contents: -1. Fuse type -- 1.1 Minimal Backup (Standard IoBroker Backup) -- 1.2 Complete backup -- 1.3 CCU backup (CCU original / pivCCU / Raspberrymatic) -- 1.4 Optional Mysql backup (Localhost) +2. preparation -3. Ftp against CIFS +3. Ftp vs. CIFS 4. Use -- 4.1 created data points -- 4.3 Format History Log with CCS -- 4.4 Display backup status in the OneClick button + - 4.1 Created data points + - 4.3 Formatting the History Log with CCS + - 4.4 Displaying the backup status in the OneClick button + 5. Restore a backup -- 5.1 Restore minimal backup -- 5.2 Restore completely backup -- 5.3 Restore Raspberryematic / CCU Backup -6. Troubleshooting -- Activate 6.1 Logging -- 6.2 Enable debugging -7. Errors / Solutions encountered -- 7.1 Web interface not accessible after Restore -- 7.2 JS-Databutt not writable -- 7.3 Error message: "Command not found" -- 7.4 Complete backup is retained -- 7.5 Rated values ​​in Dp are not accepted -8. Change log - - -## 1. Backuptype: - -Backitup offers the possibility to carry out three types (optionally with DB backup) of different backup types cyclically or at the push of a button. Each backup is placed in the / opt / iobroker / backups / directory by default. Optionally, an FTP upload can be set up or alternatively a CIFS mount can be used. - -1. Standard Backup - - This backup corresponds to the backup contained in IoBroker which can be started in the console via the call "./iobroker backup". However, it is done here through the specified settings in the adapter configuration or the OneClick Backup widget without having to use the console. -2. Complete backup - - This backup secures the complete IoBroker folder including all subfolders and their files including file permissions. In this case, the file size should not be ignored, because such a backup often has several hundred MB. -To make sure that all the latest states have to be backed up, you have to set this in the configuration of the hack at IoBroker Stop / Start. + - 5.1 Restoring a minimal backup + - 5.2 Restore full backup + - 5.3 Restore Raspberrymatic/CCU backup + +6 Troubleshooting + - 6.1 Activate logging + - 6.2 Enable debugging + +7. Occurred errors / solutions + - 7.1 Web interface not accessible after restore + - 7.2 JS data point cannot be written to + - 7.3 Error message: "Command not found + - 7.4 Complete backup hangs + - 7.5 Changed values in Dp are not accepted + +8. Changelog + + +## 1. Backup types: + +Backitup offers the possibility to perform three different backup types (optionally with DB backup) cyclically or at the push of a button. By default, each backup is stored in the /opt/iobroker/backups/ directory. Optionally, an FTP upload can be set up or alternatively a CIFS mount can be used. + +1. Standard backup + - This backup corresponds to the backup contained in IoBroker which can be started in the console by calling"./iobroker backup". However, here it is performed by the settings defined in the adapter configuration or the OneClick Backup widget without having to use the console. +2. Full backup + - This backup backs up the complete IoBroker folder including all subfolders and their files including file permissions. The file size should not be ignored, as such a backup often has several hundred MB. +To make sure that all current states are backed up, you have to set this in the configuration of the IoBroker Stop/Start hacks. 3. CCU Backup (Homematic) - - This backup offers the possibility to save 3 different variants of a homematic installation (CCU original / pivCCU / Raspberrymatic). The execution of this backup can also be done through the settings specified in the adapter configuration or the OneClick Backup widget. -4. mysql backup (localhost) - - This separately adjustable backup, if activated, will be created for every backup whether "minimal" or "complete" and will be deleted after expiration of the specified retention time. FTP or CIFS are also valid for this backup unless set for the other IoBroker backup types. + - This backup offers the possibility to backup 3 different variants of a Homematic installation (CCU-Original / pivCCU / Raspberrymatic). This backup can also be performed using the settings defined in the adapter configuration or the OneClick Backup widget. +4. mysql backup (local host) + - If activated, this separately adjustable backup is created for each backup, regardless of whether "minimal" or "complete", and is also deleted after the specified retention time has elapsed. FTP or CIFS are also valid for this backup if set for the other IoBroker backup types. + +## 3. prep: -## 2. Preparation: +The following steps should be performed to use the adapter (if the backup script v1/v2/v3 was used, first delete everything (disable or delete Data Points/Enum.functions/Shell-Script and JavaScript!) -The following steps should be used to use the adapter (if the v1 / v2 / v3 backup script was used, first delete everything (disable / delete data points / enum.functions / shell script and javascript!) +## 3. Use Ftp service or CIFS for optional backup to a Nas? -## 3. Ftp service or CIFS for the optional further secure on a Nas benefit? + - Advantages of CIFS: + - Fewer write cycles on your disk (possibly relevant if Raspberry with SD card is used to protect it) + - It is possible to have the "old backups" automatically deleted on the nas + - Disadvantages of CIFS: + - If mounting is not possible, no backup is created! + - Old backups" can be automatically deleted on the Nas. In the worst case there is no backup available if you need it. + - Path information (note spelling): + - CIFS: "Share Name/Path Specification + - FTP:"/Path specification - - Benefits CIFS: - - less write cycles on your data carrier (possibly relevant if Raspberry with SD card is used to protect this) - - It is possible to automatically delete the "old backups" on the Nas - - No need of lftp service since your nas is mounted directly. - - Disadvantages CIFS: - - If a mount is not possible, no backup is created! - - "Old backups" can be automatically deleted on the Nas. In the worst case, there is no backup available if you need it. -- Path information (note spelling): - - CIFS: "Sharename/path" - - FTP: "/path" +## 4. Use: -1. The adapter creates 7 data points for use in Vis -- start_ccu_Backup -> serves as trigger trigger for a CCU backup (can be set to true in Vis by a button) -- start_minimal_Backup -> serves as trigger trigger for a standard backup (Can be set to true in Vis by a button) -- start_komplett_Backup -> serves as trigger trigger for a complete backup (Can be set to true in Vis by a button) +The adapter creates 7 data points for use in Vis + - start_ccu_Backup -> serves as trigger for a CCU backup (can be set to true in Vis by a button) + - start_minimal_Backup -> serves as trigger for a standard backup (can be set to true in Vis by a button) + - start_komplett_Backup -> serves as trigger for a complete backup (can be set to true in Vis by a button) -- Backup_history -> dieshn as a history-log which in Vis via CCS is customizable by the design. -- Last_ccu_Backup -> stores the creation date and time of the last CCU backup -- Last_minimal_Backup -> stores the creation date and time of the last standard backup -- Last_ccu_Backup -> saves the creation date and time of the last complete backup + - Backup_history -> diehnt as history log which is customizable in Vis via CCS from the design. + - last_ccu_Backup -> saves the creation date and time of the last CCU backup + - last_minimum_backup -> saves the creation date and time of the last standard backup + - last_ccu_Backup -> saves the creation date and time of the last full backup -2. Show history log in Vis -It is possible to display the history log eg in a html widget by entering the following line in HTML: +2. show history log in Vis + - It is possible to display the history log in an html widget by entering the following line in HTML: ``` {backitup.0.History.Backup_history} ``` -Syntax: {BackitupInstanz.History.Backup_history} +Syntax: {BackitupInstance.History.Backup_history} -3. CCS Formatting of the History Log: - ``` + +3. CCS formatting of the history log +``` .backup_history{ - display:block; - width:100%; - /* overflow-y:scroll; */ - } - .bkptyp_minimal - { - float:left; - color:white; - font-size:18px; - } - .bkptyp_komplett - { - float:left; - color:yellow; - font-size:18px; - } - .bkptyp_ccu - { - float:left; - color:red; - font-size:18px; - } + display:block; + width:100%; + /* overflow-y:scroll; */ + } + .bkptyp_minimal + { + float:left; + color:white; + font-size:18px; + } + .bkptyp_komplett + { + float:left; + color:yellow; + font-size:18px; + } + .bkptyp_ccu + { + float:left; + color:red; + font-size:18px; + } ``` 4. OneClick button with status text -If a OneClick data point is set to true, the corresponding backup starts and after a predefined time, this data point is set to false again, so it is possible to create a button with status by adjusting the following line and entering it in Vis as button text: + - If a OneClick data point is set to true the corresponding backup starts and after a predefined time this data point is set to false again so it is possible to create a button with status, adjust the following line and enter it in Vis as button text: ``` -{Value: backitup.0.OneClick.start_minimal_Backup; worth === "true"? "Minimal Backup will be created": "Minimal Backup start"} +{value:backitup.0.OneClick.start_minimal_Backup; value === "true" ? "Minimal Backup
will be created" : "Minimal Backup
starten"} + ``` -Syntax: {value: BackitupInstance.OnClick.Solution trigger; worth === "true"? "Text during backup creation": "Standard text"} +Syntax: {value:BackitupInstance.OnClick.trigger; value ==="true"? "Text during backup creation": "Standard text"} ## 5. Restore: -1. Restore a minimal / normal IoBroker backup: - - The backup must be in the "opt / iobroker / backups /" directory as usual - - It can be restored via the console using the command: "iobroker restore (number of backup from the list)". - -2. Restore a complete backup: - - Execute the command: "sudo iobroker stop" via the console - - The created backup must be copied to the directory "root /" - - Run the command: "sudo tar -xzvf Backupname.tar.gz -C /" from the console - - Wait - During the restoration you will see what is being done - - Execute the command: "sudo iobroker start" via the console - -3. Restore a Raspberrymatic / CCU backup: - - Copy the * .sbk file via SCP to the directory "/ usr / local / tmp directory" on the Raspberrymatic - - Log into the Raspberrymatic via the console as the root user - - Run the command: "/bin/restoreBackup.sh / user / local / tmp / yourbackupfilename" on the raspberrymatic. +1. restore a minimal / normal IoBroker backup: + - The backup must be in the "opt/iobroker/backups/" directory as usual + - It can be restored from the console using the command: "iobroker restore (number of the backup from the list)". + +2. restore a complete backup: + - Run the command: "sudo iobroker stop" from the console + - The created backup must be copied to the "root/" directory + - Execute the command:" sudo tar -xzvf Backupname.tar.gz -C / " from the console + - Wait - During recovery you will be shown what is currently being done + - Run the command: "sudo iobroker start" from the console + +3. restore a Raspberrymatic / CCU backup: + - Copy *.sbk file via SCP into the directory " /usr/local/tmp directory" on the Raspberrymatic + - Log in via the console as root user on the Raspberrymatic + - Run the command: "/bin/restoreBackup.sh /user/local/tmp/EuerBackupFilename" on the Raspberrymatic. - Execute the command: "reboot" on the Raspberrymatic to restart the PI -Alternatively, the backup can of course also be restored as usual via the web interface. +Alternatively, the backup can be restored via the web interface as usual. ## 6. Troubleshooting: -1. In the adapter configuration there is the possibility to activate log so in the IoBroker log various messages (eg backup times and states) that can be used for troubleshooting are listed +1. In the adapter configuration there is the possibility to activate log, so the IoBroker log lists different messages (e.g. backup times and states) which can be used for troubleshooting -2. In addition, there is the possibility to enable debug now in the IoBroker log the command is issued which is passed to the backitup.sh. This command can be entered one-to-one in the console (with Putty or similar) to limit errors. +In addition there is the possibility to activate debug now the command which is passed to the backitup.sh is displayed in the IoBroker log. This command can be entered one to one into the console (with Putty or similar) to limit errors. -## 7. Errors / Solutions encountered: +## 7. occured errors / solutions: -Here is a list of problems encountered so far and their solutions, if any. +Here is a list of the problems encountered so far and their solutions, if any. -1. Olifall (from the forum) had the problem that after the Restore the web interface of the IoBrokers was not attainable, by the following steps over the console he could fix this: +1. olifall (from the forum) had the problem that after the restore the web interface of the IoBroker was no longer accessible, he could fix this by following steps via the console: - sudo iobroker status - - Message = "No connection to states 127.0.0.0:6379[redis" + - Message ="No connection to states 127.0.0.0.0:6379[redis]" - sudo apt-get install redis-server -2. During testing, others found that some data points were not writable / changeable; this error could not be corrected and therefore not resolved. - -3. Error message: "Command not found" -Due to the differences between Unix and Windows, the backitup.sh must not be changed under Windows (Editor). -Statement: -In DOS, a line end is represented by the sequence return (decimal code 13) and new line (decimal code 10) in text files. Unix uses only new line. - -4. Iobroker gets stuck during the complete backup / does not start anymore -Some users reported that the IoBroker full backup did not go through properly or the IoBroker stopped and did not start. For this purpose it is possible to deactivate the stop / start of the IoBroker in the complete backup in the adapter configuration data points. - -## 8. Changelog: - -# 0.1.4 (03.07.2018) - - (simatec / peoples) various adjustments - -# 0.1.3 (02.07.2018) - - (simatec / peoples) languages ​​added +2. during testing some data points could not be described / changed by others, this error could not be readjusted and therefore could not be corrected. -# 0.1.2 (30.06.2018) - - (simatec / peoples) First beta release +3. error message: "Command not found +Due to the differences between Unix and Windows, the backitup.sh may not be changed under Windows (Editor). +Explanation: +Under DOS, a line end is represented in text files by the sequence return (decimal code 13) and new line (decimal code 10). Unix, on the other hand, only uses new line. -# 0.1.0 (25.06.2018) - - (simatec / peoples) First Git adapter version \ No newline at end of file +4. iobroker hangs during complete backup / no longer starts +Some users reported that the IoBroker complete backup does not run correctly or that the IoBroker is stopped and not started anymore. For this purpose it is possible to deactivate the stop/start of the IoBroker during a complete backup in the adapter configuration data points. From ec3141c243aab1bbf7ac7a2ef66e4e2cc80b618d Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Sat, 14 Jul 2018 19:36:16 +0200 Subject: [PATCH 3/3] (bluefox) delete README_english.md --- README.md | 1 + README_english.md | 228 ---------------------------------------------- 2 files changed, 1 insertion(+), 228 deletions(-) delete mode 100644 README_english.md diff --git a/README.md b/README.md index abb9c0f6..e9523951 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ [![NPM](https://nodei.co/npm/iobroker.backitup.png?downloads=true)](https://nodei.co/npm/iobroker.backitup/) ***[English Description](docs/en/backitup.md)*** + ***[Deutsche Beschreibung](docs/de/backitup.md)*** ## Changelog diff --git a/README_english.md b/README_english.md deleted file mode 100644 index 79d0fbb6..00000000 --- a/README_english.md +++ /dev/null @@ -1,228 +0,0 @@ -![Logo](admin/backitup.png) -# ioBroker.backitup -================= - -[![NPM version](http://img.shields.io/npm/v/iobroker.backitup.svg)](https://www.npmjs.com/package/iobroker.backitup) -[![Downloads](https://img.shields.io/npm/dm/iobroker.backitup.svg)](https://www.npmjs.com/package/iobroker.backitup) - -[![NPM](https://nodei.co/npm/iobroker.backitup.png?downloads=true)](https://nodei.co/npm/iobroker.backitup/) - - -English Description: -================================ -***Translation by https://www.deepl.com/translator*** - -Backitup is a backup solution that allows cyclical backup of an IoBroker installation and a Homematic CCU. - -In the current version the adapter only works on Linux, because the error-free execution of the shell script does NOT work on other distributions. - -## Table of contents: -1st backup type - - 1.1 Minimum Backup (Standard IoBroker Backup) - - 1.2 Full backup - - 1.3 CCU Backup (original CCU / pivCCU / Raspberrymatic) - - 1.4 Optional mysql backup (local host) - -2. preparation - -3. Ftp vs. CIFS - -4. Use - - 4.1 Created data points - - 4.3 Formatting the History Log with CCS - - 4.4 Displaying the backup status in the OneClick button - -5. Restore a backup - - 5.1 Restoring a minimal backup - - 5.2 Restore full backup - - 5.3 Restore Raspberrymatic/CCU backup - -6 Troubleshooting - - 6.1 Activate logging - - 6.2 Enable debugging - -7. Occurred errors / solutions - - 7.1 Web interface not accessible after restore - - 7.2 JS data point cannot be written to - - 7.3 Error message: "Command not found - - 7.4 Complete backup hangs - - 7.5 Changed values in Dp are not accepted - -8. Changelog - - -## 1. Backup types: - -Backitup offers the possibility to perform three different backup types (optionally with DB backup) cyclically or at the push of a button. By default, each backup is stored in the /opt/iobroker/backups/ directory. Optionally, an FTP upload can be set up or alternatively a CIFS mount can be used. - -1. Standard backup - - This backup corresponds to the backup contained in IoBroker which can be started in the console by calling"./iobroker backup". However, here it is performed by the settings defined in the adapter configuration or the OneClick Backup widget without having to use the console. -2. Full backup - - This backup backs up the complete IoBroker folder including all subfolders and their files including file permissions. The file size should not be ignored, as such a backup often has several hundred MB. -To make sure that all current states are backed up, you have to set this in the configuration of the IoBroker Stop/Start hacks. -3. CCU Backup (Homematic) - - This backup offers the possibility to backup 3 different variants of a Homematic installation (CCU-Original / pivCCU / Raspberrymatic). This backup can also be performed using the settings defined in the adapter configuration or the OneClick Backup widget. -4. mysql backup (local host) - - If activated, this separately adjustable backup is created for each backup, regardless of whether "minimal" or "complete", and is also deleted after the specified retention time has elapsed. FTP or CIFS are also valid for this backup if set for the other IoBroker backup types. - -## 3. prep: - -The following steps should be performed to use the adapter (if the backup script v1/v2/v3 was used, first delete everything (disable or delete Data Points/Enum.functions/Shell-Script and JavaScript!) - - -## 3. Use Ftp service or CIFS for optional backup to a Nas? - - - Advantages of CIFS: - - Fewer write cycles on your disk (possibly relevant if Raspberry with SD card is used to protect it) - - It is possible to have the "old backups" automatically deleted on the nas - - Disadvantages of CIFS: - - If mounting is not possible, no backup is created! - - Old backups" can be automatically deleted on the Nas. In the worst case there is no backup available if you need it. - - Path information (note spelling): - - CIFS: "Share Name/Path Specification - - FTP:"/Path specification - - -## 4. Use: - -The adapter creates 7 data points for use in Vis - - start_ccu_Backup -> serves as trigger for a CCU backup (can be set to true in Vis by a button) - - start_minimal_Backup -> serves as trigger for a standard backup (can be set to true in Vis by a button) - - start_komplett_Backup -> serves as trigger for a complete backup (can be set to true in Vis by a button) - - - Backup_history -> diehnt as history log which is customizable in Vis via CCS from the design. - - last_ccu_Backup -> saves the creation date and time of the last CCU backup - - last_minimum_backup -> saves the creation date and time of the last standard backup - - last_ccu_Backup -> saves the creation date and time of the last full backup - -2. show history log in Vis - - It is possible to display the history log in an html widget by entering the following line in HTML: -``` -{backitup.0.History.Backup_history} -``` -Syntax: {BackitupInstance.History.Backup_history} - - -3. CCS formatting of the history log -``` - .backup_history{ - display:block; - width:100%; - /* overflow-y:scroll; */ - } - .bkptyp_minimal - { - float:left; - color:white; - font-size:18px; - } - .bkptyp_komplett - { - float:left; - color:yellow; - font-size:18px; - } - .bkptyp_ccu - { - float:left; - color:red; - font-size:18px; - } - ``` -4. OneClick button with status text - - If a OneClick data point is set to true the corresponding backup starts and after a predefined time this data point is set to false again so it is possible to create a button with status, adjust the following line and enter it in Vis as button text: -``` -{value:backitup.0.OneClick.start_minimal_Backup; value === "true" ? "Minimal Backup
will be created" : "Minimal Backup
starten"} - -``` -Syntax: {value:BackitupInstance.OnClick.trigger; value ==="true"? "Text during backup creation": "Standard text"} - -## 5. Restore: - -1. restore a minimal / normal IoBroker backup: - - The backup must be in the "opt/iobroker/backups/" directory as usual - - It can be restored from the console using the command: "iobroker restore (number of the backup from the list)". - -2. restore a complete backup: - - Run the command: "sudo iobroker stop" from the console - - The created backup must be copied to the "root/" directory - - Execute the command:" sudo tar -xzvf Backupname.tar.gz -C / " from the console - - Wait - During recovery you will be shown what is currently being done - - Run the command: "sudo iobroker start" from the console - -3. restore a Raspberrymatic / CCU backup: - - Copy *.sbk file via SCP into the directory " /usr/local/tmp directory" on the Raspberrymatic - - Log in via the console as root user on the Raspberrymatic - - Run the command: "/bin/restoreBackup.sh /user/local/tmp/EuerBackupFilename" on the Raspberrymatic. - - Execute the command: "reboot" on the Raspberrymatic to restart the PI - -Alternatively, the backup can be restored via the web interface as usual. - -## 6. Troubleshooting: - -1. In the adapter configuration there is the possibility to activate log, so the IoBroker log lists different messages (e.g. backup times and states) which can be used for troubleshooting - -In addition there is the possibility to activate debug now the command which is passed to the backitup.sh is displayed in the IoBroker log. This command can be entered one to one into the console (with Putty or similar) to limit errors. - -## 7. occured errors / solutions: - -Here is a list of the problems encountered so far and their solutions, if any. - -1. olifall (from the forum) had the problem that after the restore the web interface of the IoBroker was no longer accessible, he could fix this by following steps via the console: - - sudo iobroker status - - Message ="No connection to states 127.0.0.0.0:6379[redis]" - - sudo apt-get install redis-server - -2. during testing some data points could not be described / changed by others, this error could not be readjusted and therefore could not be corrected. - -3. error message: "Command not found -Due to the differences between Unix and Windows, the backitup.sh may not be changed under Windows (Editor). -Explanation: -Under DOS, a line end is represented in text files by the sequence return (decimal code 13) and new line (decimal code 10). Unix, on the other hand, only uses new line. - -4. iobroker hangs during complete backup / no longer starts -Some users reported that the IoBroker complete backup does not run correctly or that the IoBroker is stopped and not started anymore. For this purpose it is possible to deactivate the stop/start of the IoBroker during a complete backup in the adapter configuration data points. - -## 7. Changelog - -### 0.1.8 (11.07.2018) - (darkiop) MySQL backup extended by host and port query - (peoples) sending telegram instance selectable - (peoples) telegram messages adapted to connection type - (peoples) history log adapted to connection type - (simatec) compression of MySQL database backup implemented - (simatec) Adaptation of the configuration interface to the telegram instance Selection - -### 0.1.7 (05.07.2018) - (peoples) data points defined in io-package - -### 0.1.6 (04.07.2018) - (simatec/peoples) Beta Version - -### 0.1.5 (03.07.2018) - (peoples) Log entries reformatted - -### 0.1.4 (02.07.2018) - (simatec/peoples) various adjustments - -### 0.1.3 (01.07.2018) - (simatec/peoples) languages added - -### 0.1.2 (30.06.2018) - (simatec/peoples) First beta version - -### 0.1.0 (25.06.2018) - (simatec/peoples) First git adapter version - -## License - -The MIT License (MIT) - -Copyright (c) 2018 simatec - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files ("Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following \ No newline at end of file