diff --git a/fhem/CHANGED b/fhem/CHANGED index 28fdbe752..073ce24b4 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - change: 93_DbRep: improve 'restore' setlist, revised comRef - feature: 82_LGTV_WebOS: add DuplexIPTV App support - feature: 00_RSS: new img type SVG (forum #111271) - bugfix: 73_AutoShuttersControl: fix bug after privacyDown and open window diff --git a/fhem/FHEM/93_DbRep.pm b/fhem/FHEM/93_DbRep.pm index 6c19f4306..9e3d19c0e 100644 --- a/fhem/FHEM/93_DbRep.pm +++ b/fhem/FHEM/93_DbRep.pm @@ -58,6 +58,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch'; # Version History intern our %DbRep_vNotesIntern = ( + "8.40.1" => "18.05.2020 improve 'restore' setlist, revised comRef, fix compare timesettings for delEntries,reduceLog ", "8.40.0" => "30.03.2020 new attribute 'autoForward' ", "8.39.0" => "28.03.2020 option 'writeToDBInTime' for function 'sumValue' and 'averageValue' ", "8.38.0" => "21.03.2020 sqlSpecial readingsDifferenceByTimeDelta, fix FHEM crash if no time-attribute is set and time ". @@ -541,12 +542,12 @@ sub DbRep_Set($@) { opendir(DIR,$dir); if ($dbmodel =~ /MYSQL/) { $dbname = $hash->{DATABASE}; - $sd = $dbname.".*(csv|sql)"; + $sd = $dbname."_.*?(csv|sql)"; } elsif ($dbmodel =~ /SQLITE/) { $dbname = $hash->{DATABASE}; $dbname = (split /[\/]/, $dbname)[-1]; $dbname = (split /\./, $dbname)[0]; - $sd = $dbname."_.*.sqlitebkp"; + $sd = $dbname."_.*?.sqlitebkp"; } while (my $file = readdir(DIR)) { next unless (-f "$dir/$file"); @@ -807,7 +808,9 @@ sub DbRep_Set($@) { return " Set attribute 'allowDeletion' if you want to allow deletion of any database entries. Use it with care !"; } delete $hash->{HELPER}{DELENTRIES}; - $hash->{HELPER}{DELENTRIES} = \@a; + shift @a; + shift @a; + $hash->{HELPER}{DELENTRIES} = \@a if(@a); DbRep_beforeproc($hash, "delEntries"); DbRep_Main($hash,$opt); @@ -1838,12 +1841,14 @@ sub DbRep_dbConnect($$) { } } - eval { $dbh = DBI->connect("dbi:$dbconn", $dbuser, $dbpassword, { PrintError => 0, - RaiseError => 1, - AutoCommit => 1, + eval { $dbh = DBI->connect("dbi:$dbconn", $dbuser, $dbpassword, { PrintError => 0, + RaiseError => 1, + AutoCommit => 1, AutoInactiveDestroy => 1, - mysql_enable_utf8 => $utf8 - } ); }; + mysql_enable_utf8 => $utf8 + } + ); + }; if ($@) { $err = $@; @@ -2037,10 +2042,10 @@ sub DbRep_Main($$;$) { } elsif ($opt eq "delEntries") { my ($yyyy1, $mm1, $dd1, $hh1, $min1, $sec1) = ($runtime_string_first =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/); - my ($yyyy2, $mm2, $dd2, $hh2, $min2, $sec2) = ($runtime_string_next =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/); + my ($yyyy2, $mm2, $dd2, $hh2, $min2, $sec2) = ($runtime_string_next =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/); my $nthants = timelocal($sec1, $min1, $hh1, $dd1, $mm1-1, $yyyy1-1900); my $othants = timelocal($sec2, $min2, $hh2, $dd2, $mm2-1, $yyyy2-1900); - if($nthants >= $othants) { + if($nthants > $othants) { ReadingsSingleUpdateValue ($hash, "state", "Error - Wrong time limits. The (days newer than) option must be greater than the (older than) one !", 1); return; } @@ -2139,7 +2144,7 @@ sub DbRep_Main($$;$) { my ($yyyy2, $mm2, $dd2, $hh2, $min2, $sec2) = ($runtime_string_next =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/); my $nthants = timelocal($sec1, $min1, $hh1, $dd1, $mm1-1, $yyyy1-1900); my $othants = timelocal($sec2, $min2, $hh2, $dd2, $mm2-1, $yyyy2-1900); - if($nthants >= $othants) { + if($nthants > $othants) { ReadingsSingleUpdateValue ($hash, "state", "Error - Wrong time limits. The (days newer than) option must be greater than the (older than) one !", 1); return; } @@ -4347,24 +4352,26 @@ sub del_DoParse($) { # Background-Startzeit my $bst = [gettimeofday]; - eval {$dbh = DBI->connect("dbi:$dbconn", $dbuser, $dbpassword, { PrintError => 0, RaiseError => 1, AutoCommit => 1, AutoInactiveDestroy => 1 });}; - - if ($@) { - $err = encode_base64($@,""); - Log3 ($name, 2, "DbRep $name - $@"); - return "$name|''|''|$err|''|''|''"; - } - # ist Zeiteingrenzung und/oder Aggregation gesetzt ? (wenn ja -> "?" in SQL sonst undef) my ($IsTimeSet,$IsAggrSet) = DbRep_checktimeaggr($hash); Log3 ($name, 5, "DbRep $name - IsTimeSet: $IsTimeSet, IsAggrSet: $IsAggrSet"); + BlockingInformParent("DbRep_delHashValFromBlocking", [$name, "HELPER","DELENTRIES"], 1); + # SQL zusammenstellen für DB-Operation if ($IsTimeSet || $IsAggrSet) { $sql = DbRep_createDeleteSql($hash,$table,$device,$reading,$runtime_string_first,$runtime_string_next,''); } else { $sql = DbRep_createDeleteSql($hash,$table,$device,$reading,undef,undef,''); } + + eval {$dbh = DBI->connect("dbi:$dbconn", $dbuser, $dbpassword, { PrintError => 0, RaiseError => 1, AutoCommit => 1, AutoInactiveDestroy => 1 });}; + + if ($@) { + $err = encode_base64($@,""); + Log3 ($name, 2, "DbRep $name - $@"); + return "$name|''|''|$err|''|''|''"; + } $sth = $dbh->prepare($sql); @@ -8263,7 +8270,7 @@ sub mysql_RestoreClientSide($) { my $bst = [gettimeofday]; # Verbindung mit DB - eval {$dbh = DBI->connect("dbi:$dbconn", $dbuser, $dbpassword, { PrintError => 0, RaiseError => 1, AutoCommit => 1 });}; + eval {$dbh = DBI->connect("dbi:$dbconn", $dbuser, $dbpassword, { PrintError => 0, RaiseError => 1, AutoInactiveDestroy => 1, AutoCommit => 1 });}; if ($@) { $e = $@; $err = encode_base64($e,""); @@ -8498,7 +8505,7 @@ sub DbRep_syncStandby($) { my $bst = [gettimeofday]; # Verbindung zur Quell-DB - eval {$dbh = DBI->connect("dbi:$dbconn", $dbuser, $dbpassword, { PrintError => 0, RaiseError => 1, AutoCommit => 1, mysql_enable_utf8 => $utf8 });}; + eval {$dbh = DBI->connect("dbi:$dbconn", $dbuser, $dbpassword, { PrintError => 0, RaiseError => 1, AutoCommit => 1, AutoInactiveDestroy => 1, mysql_enable_utf8 => $utf8 });}; if ($@) { $err = encode_base64($@,""); Log3 ($name, 2, "DbRep $name - $@"); @@ -12567,12 +12574,12 @@ return;
    - - - + + + - - + +
    dumpCompress : compress of dump files after creation
    dumpDirLocal : the local mounted directory dumpDirRemote
    dumpFilesKeep : number of dump files to keep
    dumpCompress : compress of dump files after creation
    dumpDirLocal : Target directory of the dumpfiles
    dumpFilesKeep : number of dump files to keep
    executeBeforeProc : execution of FHEM command (or Perl-routine) before dump
    executeAfterProc : execution of FHEM command (or Perl-routine) after dump
    optimizeTablesBeforeDump : table optimization before dump
    executeAfterProc : execution of FHEM command (or Perl-routine) after dump
    optimizeTablesBeforeDump : table optimization before dump

@@ -13020,16 +13027,16 @@ return; Usage of serverSide-Dumps
The content of history-table will be restored from a serverSide-Dump. Therefore the remote directory "dumpDirRemote" of the MySQL-Server has to be mounted on the - Client and make it usable to the DbRep-device by setting attribute - "dumpDirLocal" to the appropriate value.
+ Client and make it usable to the DbRep device by setting attribute dumpDirLocal + to the appropriate value.
All files with extension "csv[.gzip]" and if the filename is beginning with the name of the connected database (see Internal DATABASE) are listed.

Usage of clientSide-Dumps
All tables and views (if present) are restored. - The directory which contains the dump files has to be set by attribute - "dumpDirLocal" to make it usable by the DbRep device.
+ The directory which contains the dump files has to be set by attribute dumpDirLocal + to make it usable by the DbRep device.
All files with extension "sql[.gzip]" and if the filename is beginning with the name of the connected database (see Internal DATABASE) are listed.
The restore speed depends of the server variable "max_allowed_packet". You can change @@ -13620,11 +13627,11 @@ return $ret;
  • dumpCompress - if set, the dump files are compressed after operation of "dumpMySQL" bzw. "dumpSQLite"

  • -
  • dumpDirLocal - Target directory of database dumps by command "dumpMySQL clientSide" +
  • dumpDirLocal - Target directory of database dumps by command "dumpMySQL clientSide" or "dumpSQLite" (default: "{global}{modpath}/log/" on the FHEM-Server).
    In this directory also the internal version administration searches for old backup-files and deletes them if the number exceeds attribute "dumpFilesKeep". - The attribute is also relevant to publish a local mounted directory "dumpDirRemote" to + The attribute is also relevant to publish a local mounted directory "dumpDirRemote" (dumpMySQL serverSide) to DbRep.

  • @@ -15136,12 +15143,12 @@ sub bdump {
      - - - - + + + + - +
      dumpCompress : Komprimierung des Dumpfiles nach der Erstellung
      dumpDirLocal : Directory des lokal gemounteten dumpDirRemote-Verzeichnisses
      dumpFilesKeep : Anzahl der aufzubwahrenden Dumpfiles
      executeBeforeProc : ausführen FHEM Kommando (oder Perl-Routine) vor dem Dump
      dumpCompress : Komprimierung des Dumpfiles nach der Erstellung
      dumpDirLocal : Zielverzeichnis der Dumpfiles
      dumpFilesKeep : Anzahl der aufzubwahrenden Dumpfiles
      executeBeforeProc : ausführen FHEM Kommando (oder Perl-Routine) vor dem Dump
      executeAfterProc : ausführen FHEM Kommando (oder Perl-Routine) nach dem Dump
      optimizeTablesBeforeDump : Tabelloptimierung vor dem Dump ausführen
      optimizeTablesBeforeDump : Tabelloptimierung vor dem Dump ausführen

    @@ -15610,14 +15617,14 @@ sub bdump { Verwendung eines serverSide-Dumps
    Es wird der Inhalt der history-Tabelle aus einem serverSide-Dump wiederhergestellt. Dazu ist das Verzeichnis "dumpDirRemote" des MySQL-Servers auf dem Client zu mounten - und im Attribut "dumpDirLocal" dem DbRep-Device bekannt zu machen.
    + und im Attribut dumpDirLocal dem DbRep-Device bekannt zu machen.
    Es werden alle Files mit der Endung "csv[.gzip]" und deren Name mit der verbundenen Datenbank beginnt (siehe Internal DATABASE), aufgelistet.

    Verwendung eines clientSide-Dumps
    Es werden alle Tabellen und eventuell vorhandenen Views wiederhergestellt. - Das Verzeichnis, in dem sich die Dump-Files befinden, ist im Attribut "dumpDirLocal" dem + Das Verzeichnis, in dem sich die Dump-Files befinden, ist im Attribut dumpDirLocal dem DbRep-Device bekannt zu machen.
    Es werden alle Files mit der Endung "sql[.gzip]" und deren Name mit der verbundenen Datenbank beginnt (siehe Internal DATABASE), aufgelistet.
    @@ -16224,11 +16231,11 @@ return $ret;
  • dumpCompress - wenn gesetzt, werden die Dumpfiles nach "dumpMySQL" bzw. "dumpSQLite" komprimiert

  • -
  • dumpDirLocal - Zielverzeichnis für die Erstellung von Dumps mit "dumpMySQL clientSide". +
  • dumpDirLocal - Zielverzeichnis für die Erstellung von Dumps mit "dumpMySQL clientSide" oder "dumpSQLite". default: "{global}{modpath}/log/" auf dem FHEM-Server.
    - Ebenfalls werden in diesem Verzeichnis alte Backup-Files durch die interne Versionsverwaltung von - "dumpMySQL" gesucht und gelöscht wenn die gefundene Anzahl den Attributwert "dumpFilesKeep" - überschreitet. Das Attribut dient auch dazu ein lokal gemountetes Verzeichnis "dumpDirRemote" + Ebenfalls werden in diesem Verzeichnis alte Backup-Files durch die interne Versionsverwaltung + gesucht und gelöscht wenn die gefundene Anzahl den Attributwert "dumpFilesKeep" + überschreitet. Das Attribut dient auch dazu ein lokal gemountetes Verzeichnis "dumpDirRemote" (bei dumpMySQL serverSide) DbRep bekannt zu machen.