Skip to content

Commit

Permalink
Version 0.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
peoples0815 committed Jul 11, 2018
1 parent 17bf429 commit da7291c
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 23 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ Einige Benutzer berichteten dass das IoBroker komplett-Backup nicht richtig durc

## Changelog

### 0.1.8 (11.07.2018)
* (darkiop) MySQL-Sicherung um Host- und Portabfrage erweitert
* (peoples) Versendende Telegram-Instanz wählbar
* (peoples) Telegram-Nachrichten angepasst an Verbindungstyp
* (peoples) History-Log angepasst an Verbindungstyp
* (simatec) Komprimierung der MySQL-Datenbank-Sicherung eingebaut
* (simatec) Anpassung der Konfigoberfläche an Telegram-Instanz Auswahl

### 0.1.7 (05.07.2018)
* (peoples) Datenpunkte in io-package definiert

Expand Down
36 changes: 27 additions & 9 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,27 @@
showHideSettings();
onChange(false);
M.updateTextFields(); // function Materialize.updateTextFields(); to reinitialize all the Materialize labels on the page if you are dynamically adding inputs.
}



getAdapterInstances('telegram', function (arr) {
instances = arr;
fillInstances('Telegram_instanz', arr, settings['Telegram_instanz']);
});


}
function fillInstances(id, arr, val) {
var $sel = $('#' + id);
$sel.html('<option value="">' + _('none') + '</option>');
var _id;
for (var i = 0; i < arr.length; i++) {
var _id = arr[i]._id.replace('system.adapter.', '');
// Take first value
// if (!val) val = _id;
$sel.append('<option value="' + _id + '"' + ((_id === val) ? ' selected' : '') + '>' + _id + '</option>');
}
$sel.select();
}
// ... and the function save has to exist.
// you have to make sure the callback is called with the settings object as first param!
function save(callback) {
Expand Down Expand Up @@ -150,13 +169,12 @@
<input class="value" id="telegram_message" type="checkbox" />
<label for="Benachrichtigungen per Telegram" class="translate">Benachrichtigungen per Telegram</label>
</div>
</div>
<div class="row telegram_inst">
<div class="input-field col s12 m4 l2 telegram_inst">
<input type="number" class="value" id="telegram_instanz" min="0" max="5" />
<label for="Telegram Instanz" class="translate">Telegram Instanz</label>
<span class="translate">Telegram Instanz</span>
</div>
<div class="row telegram_inst">
<div class="input-field col s3">
<select id="Telegram_instanz" class="value" /></select>
<label for="Telegram_instanz" class="translate">Telegram Instanz</label>
</div>
</div>
</div>
<div class="row">
<div class="input-field col s12 m4 l2">
Expand Down
15 changes: 13 additions & 2 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
{
"common": {
"name": "backitup",
"version": "0.1.7",
"version": "0.1.8",
"news": {
"0.1.7": {
"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-пакете",
Expand Down
38 changes: 28 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,29 +229,39 @@ function BackupStellen() {
// # 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+'"');

// Telegram
if(adapter.config.telegram_message === true){
// 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!');
}
}

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 !== '') messagetext += ', und nach '+host+pfad+' kopiert/verschoben';
if(host !== ''){
if(cifsmnt == 'FTP') messagetext += ', und via FTP nach '+host+pfad+' kopiert/verschoben';
if(cifsmnt == 'CIFS') messagetext += ', und unter '+host+pfad+' gespeichert';
}
messagetext += '!';
adapter.sendTo("telegram", "send", {text: 'BackItUp:\n' + 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;
if(cifsmnt === 'FTP') ftp_bkp_u = 'FTP'; else ftp_bkp_u = 'CIFS';
new Backup_history_anlegen(typ, 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){
Expand Down Expand Up @@ -292,7 +302,7 @@ function HistoryEintrag(date) {
// # #
// #############################################################################

function Backup_history_anlegen(typ, ftp_bkp_u) {
function Backup_history_anlegen(typ, host, cifsmnt) {
adapter.getState('History.Backup_history', function (err, state) {
let history_liste = state.val;
if(history_liste == '<span class="bkptyp_komplett">Noch keine Backups erstellt</span>') history_liste = '';
Expand All @@ -301,7 +311,15 @@ function Backup_history_anlegen(typ, ftp_bkp_u) {
history_array.splice((anzahl_eintraege_history - 1),1);
}
let zeitstempel = HistoryEintrag(new Date());
history_array.unshift('<span class="bkptyp_'+typ+'">' + zeitstempel + ' - Typ:' +typ+ ' - NAS-Sicherung: ' +ftp_bkp_u+ '</span>');
let historytext;
if(host !== ''){
if(cifsmnt == 'FTP') historytext = '<span class="bkptyp_'+typ+'">' + zeitstempel + ' - Typ:' +typ+ ' - FTP-Sicherung: JA</span>';
if(cifsmnt == 'CIFS') historytext = '<span class="bkptyp_'+typ+'">' + zeitstempel + ' - Typ:' +typ+ ' - CIFS-Mount: JA</span>';
}
else{
historytext = '<span class="bkptyp_'+typ+'">' + zeitstempel + ' - Typ:' +typ+ ' - Nur lokal gesichert</span>';
}
history_array.unshift(historytext);

adapter.setState('History.Backup_history', history_array.join('&nbsp;'));
});
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.backitup",
"version": "0.1.7",
"version": "0.1.8",
"engines": {
"node": ">=6.0.0"
},
Expand Down

0 comments on commit da7291c

Please sign in to comment.