Tuto - vérifier l'externalisation des backups et leur cohérence

Bonjour

Lors de l’exécution du scénario vous n’avez pas de log dans scenario_execution ?

Moi j’ai cela

PHP Warning:  array_combine(): Both parameters should have an equal number of elements in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 26
0002|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 67
0003|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 67
0004|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 67
0005|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 67
0006|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 67
0007|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 67
0008|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 67
0009|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 67
0010|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 67
0011|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 67
0012|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 67
0013|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 67
0014|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 74
0015|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 74
0016|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 74
0017|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 74
0018|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 74
0019|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 74
0020|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 74
0021|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 74
0022|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 74
0023|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 74
0024|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 74
0025|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 91
0026|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 94
0027|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 95
0028|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 91
0029|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 94
0030|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 95
0031|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 91
0032|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 94
0033|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 95
0034|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 91
0035|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 94
0036|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 95
0037|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 91
0038|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 94
0039|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 95
0040|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 91
0041|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 94
0042|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 95
0043|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 91
0044|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 94
0045|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 95
0046|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 91
0047|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 94
0048|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 95
0049|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 91
0050|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 94
0051|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 95
0052|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 91
0053|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 94
0054|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 95
0055|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 91
0056|PHP Warning:  Use of undefined constant taille - assumed 'taille' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 94
0057|PHP Warning:  Use of undefined constant file - assumed 'file' (this will throw an Error in a future version of PHP) in /var/www/html/core/class/scenarioExpression.class.php(1987) : eval()'d code on line 95

Bonjour @thanaus

Cette version est-elle sortie ? Ou est-ce la version beta ?

Merci

Je confirme avoir ce type de message depuis quelques temps et je n’arrivait pas à trouver quel scénario était concerné … Je vais jeter un œil

Norbert

tu peux essayer avec ce bloc code ?

// version bloc code
$version = '27/09/2024 09:00';
$scenario->setLog('┌──────────── Logs bloc code - version du ' . $version);

/**
* Class and Function List:
* Function list:
* - csv_to_array()
* Classes list:
*/

function csv_to_array($filename  = '', $delimiter = ',') {
    if (!file_exists($filename) || !is_readable($filename)) return false;

    $header    = array(
        'taille',
        'date',
        'heure',
        'file'
    );
    $data      = array();
    if (($handle    = fopen($filename, 'r')) !== false) {
        while ( ($row = fgetcsv($handle, 1000, $delimiter)) !== false) {
            if (!$header) $header    = $row;
            else $data[]           = array_combine($header, $row);
        }
        fclose($handle);
    }
    return $data;
}

// parametres
$tags            = $scenario->getTags(); //récupère la liste des tags
$cmdIdListe      = str_replace('#', '', $tags['#cmdListe#']);
$seuilTailleMax  = $tags['#seuilTailleMax#'];
$seuilTailleMin  = $tags['#seuilTailleMin#'];
$AlerteCentreMsg = $tags['#AlerteCentreMsg#'];
$AlerteNotifJC   = $tags['#AlerteNotifJC#'];
$AlerteNotifTelegram = $tags['#AlerteNotifTelegram#'];
$fichierListe    = '/var/www/html/log/cloudsyncpro.#' . $cmdIdListe;

if ($AlerteNotifJC) $cmdNotifJC      = cmd::byString($tags['#cmdNotifJC#']);
if ($AlerteNotifTelegram) $cmdNotifTelegram      = cmd::byString($tags['#cmdNotifTelegram#']);

$scenario->setLog('| Fichier log : ' . $fichierListe);
$scenario->setLog('| Taille min  : ' . $seuilTailleMin . 'Mo');
$scenario->setLog('| Taille max  : ' . $seuilTailleMax . 'Mo');

// mise à jour de la liste
cmd::byId($cmdIdListe)->execCmd();

if (!file_exists($fichierListe) || !is_readable($fichierListe)) {
    $scenario->setLog('| /!\ le fichier ' . $fichierListe . ' n\'existe pas ou n\'est pas lisible');
    if ($AlerteCentreMsg) message::add('Backup', 'Vérification des backups, ERREUR : le fichier ' . $fichierListe . ' n\'existe pas ou n\'est pas lisible');
    if ($AlerteNotifJC) $cmdNotifJC->execCmd($options = array(
        'title'         => 'title=Defaut BACKUP ' . $site,
        'message'       => 'Vérification des backups, ERREUR : le fichier ' . $fichierListe . ' n\'existe pas ou n\'est pas lisible'
    ) , $cache   = 0);
    if ($AlerteNotifTelegram) $cmdNotifTelegram->execCmd($_options = array(
        'message'       => 'Vérification des backups, ERREUR : le fichier ' . $fichierListe . ' n\'existe pas ou n\'est pas lisible'
    ) , $cache   = 0);
} else {
    // Extraction des données du fichier dans un tableau
    $data = csv_to_array($fichierListe, ' ');

    // suppression des lignes vides
    for ($n = 0; $n < count($data); $n++) {
        if (empty($data[$n]['taille'])) {
            array_splice($data, $n, 1);
        }
    }

    // recherche des sites de backup concernés
    $sites = array();
    for ($n = 0; $n < count($data); $n++) {
        $file = explode('-', $data[$n]['file']);
        $sites[] = $file[1];
    }
    $sites = array_unique($sites);

    foreach ($sites as $site) {
        if (substr($site, 0, 4) == 'domo') {
            $nbBackup = 0;
            $tailleTotale = 0;
            $tailleMax = '';
            $tailleMin = '';
            $backupToday = 0;
            $tailleFirstBackup = 0;
            $tailleLastBackup = 0;
            $timestampFirstBackup = '';
            $timestampLastBackup = '';

            for ($n = 0; $n < count($data); $n++) {
                $file = explode('-', str_replace('_', '-', $data[$n]['file']));
                if ($site == $file[1]) {
                    $taille = round($data[$n]['taille'] / 1024 / 1024);
                    $jeedom = $file[1];
                    $version = $file[2];

                    $nbBackup++;
                    $tailleTotale += $taille;
                    if ($taille > $tailleMax || empty($tailleMax)) $tailleMax = $taille;
                    if ($taille < $tailleMin || empty($tailleMin)) $tailleMin = $taille;

                    // date des backups
                    $timestampBackup = mktime(0, 0, 0, $file[4], $file[5], $file[3]); // timestamp du backup à 0:00
                    $timestampNow = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
                    if ($timestampBackup == $timestampNow) $backupToday = 1;
                    if ($timestampBackup <= $timestampFirstBackup || empty($timestampFirstBackup)) {
                        $timestampFirstBackup = $timestampBackup;
                        $tailleFirstBackup = $taille;
                    }
                    if ($timestampBackup >= $timestampLastBackup || empty($timestampLastBackup)) {
                        $timestampLastBackup = $timestampBackup;
                        $tailleLastBackup = $taille;
                    }
                }
            }

            $scenario->setLog('| Résumé : ' . $site . ' (Version : ' . $version . ')');
            $scenario->setLog('|     Nb backup presents   : ' . $nbBackup);
            $scenario->setLog('|     1er backup dispo     : ' . date('d/m/Y', $timestampFirstBackup).' ('.$tailleFirstBackup.'Mo)');
            $scenario->setLog('|     dernier backup dispo : ' . date('d/m/Y', $timestampLastBackup).' ('.$tailleLastBackup.'Mo)');
            $scenario->setLog('|     Taille moyenne       : ' . round($tailleTotale / $nbBackup) . 'Mo');

            // gestion des erreurs
            if ($tailleMax >= $seuilTailleMax || $tailleMin <= $seuilTailleMin) {
                $scenario->setLog('| /!\ Pb de taille sur un backup - merci de verifier (taille min : ' . $tailleMin . 'Mo, max :' . $tailleMax . 'Mo)');
                if ($AlerteCentreMsg) message::add('Backup', $site . ' - Pb de taille sur une sauvegarde - merci de verifier (taille min : ' . $tailleMin . 'Mo, max :' . $tailleMax . 'Mo)');
                if ($AlerteNotifJC) $cmdNotifJC->execCmd($options = array(
                    'title'         => 'title=Defaut BACKUP ' . $site,
                    'message'       => 'Pb de taille sur un backup<br>Taille min : ' . $tailleMin . 'Mo<br>Taille max :' . $tailleMax . 'Mo'
                ) , $cache   = 0);
                if ($AlerteNotifTelegram) $cmdNotifTelegram->execCmd($_options = array(
                    'message'       => 'Pb de taille sur un backup' ."\n" .'Taille min : ' . $tailleMin . 'Mo' ."\n" .'Taille max : ' . $tailleMax . 'Mo'
                ) , $cache   = 0);
            }
            if (!$backupToday) {
                $scenario->setLog('| /!\ Pas de backup aujourd\'hui');
                if ($AlerteCentreMsg) message::add('Backup', $site . ' - Pas de backup aujourd\'hui, dernier backup : ' . date('d/m/Y', $timestampLastBackup));
                if ($AlerteNotifJC) $cmdNotifJC->execCmd($options = array(
                    'title'         => 'title=Defaut BACKUP ' . $site,
                    'message'       => 'Pas de backup aujourd\'hui<br>Dernier backup : ' . date('d/m/Y', $timestampLastBackup)
                ) , $cache   = 0);
                if ($AlerteNotifTelegram) $cmdNotifTelegram->execCmd($_options = array(
                    'message'       => 'Pas de backup aujourd\'hui Dernier backup : ' . date('d/m/Y', $timestampLastBackup)
                ) , $cache   = 0);
            }
        }
    }
}

$scenario->setLog('└───────────────────────────');

Le scénario est mega long et fini en erreur mais cela génère toujours des logs php

Bonjour,

Dans certains cas, il y a un espace dans le log. Il semblerait que ça dépende de la taille.

100767018 2025-01-20 06:55:41.357000000 backup-xxx-4.4.19-2025-01-20-07h55.tar.gz
100762875 2025-01-19 06:55:41.116000000 backup-xxx-4.4.19-2025-01-19-07h55.tar.gz
 92985716 2025-01-18 06:55:39.419000000 backup-xxx-4.4.19-2025-01-18-07h55.tar.gz
 92989530 2025-01-17 06:55:40.502000000 backup-xxx-4.4.19-2025-01-17-07h55.tar.gz

Lorsqu’il y a un espace, cela crée un décalage d’index avec une case vide. Du coup j’ai modifié la fonction csv_to_array pour supprimer cette case et que ça fonctionne à tous les coups :

function csv_to_array($filename  = '', $delimiter = ',') {
    if (!file_exists($filename) || !is_readable($filename)) return false;
    $header    = array(
        'taille',
        'date',
        'heure',
        'file'
    );
    $data      = array();
    if (($handle    = fopen($filename, 'r')) !== false) {
        while (($row       = fgetcsv($handle, 1000, $delimiter)) !== false) {
            if (empty($row[0])) {
              array_splice($row, 0, 1);
            }
            if (!$header) $header    = $row;
            else $data[]           = array_combine($header, $row);
        }
        fclose($handle);
    }
    return $data;
}
1 « J'aime »

Bonjour à tous,
Je viens de me rendre compte (totalement au hasard) que mon scenario (version « 03/05/2023 19:00 ») ne fonctionnait plus depuis un moment.

La version donnée par @ngrataloup ici ne fonctionne pas pour moi (notamment à cause d’une clause if "== « domo » non applicable chez moi).

Après retouche, voici une version qui fonctionne chez moi sans l’intégration de la notification Telegram (uniquement JeedomConnect) :

// version bloc code
$version = '03/05/2023 19:00';
$scenario->setLog('┌──────────── Logs bloc code - version du ' . $version);

/**
* Class and Function List:
* Function list:
* - csv_to_array()
* Classes list:
*/

function csv_to_array($filename  = '', $delimiter = ',') {
    if (!file_exists($filename) || !is_readable($filename)) return false;

    $header    = array(
        'taille',
        'date',
        'heure',
        'file'
    );
    $data      = array();
    if (($handle    = fopen($filename, 'r')) !== false) {
        while (($row       = fgetcsv($handle, 1000, $delimiter)) !== false) {
            if (!$header) $header    = $row;
            else $data[]           = array_combine($header, $row);
        }
        fclose($handle);
    }
    return $data;
}

// parametres
$tags            = $scenario->getTags(); //récupère la liste des tags
$cmdIdListe      = str_replace('#', '', $tags['#cmdListe#']);
$seuilTailleMax  = $tags['#seuilTailleMax#'];
$seuilTailleMin  = $tags['#seuilTailleMin#'];
$AlerteCentreMsg = $tags['#AlerteCentreMsg#'];
$AlerteNotifJC   = $tags['#AlerteNotifJC#'];
$fichierListe    = '/var/www/html/log/cloudsyncpro.#' . $cmdIdListe;
if ($AlerteNotifJC) $cmdNotifJC      = cmd::byString($tags['#cmdNotifJC#']);

$scenario->setLog('| Fichier log : ' . $fichierListe);
$scenario->setLog('| Taille min  : ' . $seuilTailleMin . 'Mo');
$scenario->setLog('| Taille max  : ' . $seuilTailleMax . 'Mo');

// mise à jour de la liste
cmd::byId($cmdIdListe)->execCmd();

if (!file_exists($fichierListe) || !is_readable($fichierListe)) {
    $scenario->setLog('| /!\ le fichier ' . $fichierListe . ' n\'existe pas ou n\'est pas lisible');
    if ($AlerteCentreMsg) message::add('Backup', 'Vérification des backups, ERREUR : le fichier ' . $fichierListe . ' n\'existe pas ou n\'est pas lisible');
    if ($AlerteNotifJC) $cmdNotifJC->execCmd($options = array(
        'title'         => 'title=Defaut BACKUP ' . $site,
        'message'       => 'Vérification des backups, ERREUR : le fichier ' . $fichierListe . ' n\'existe pas ou n\'est pas lisible'
    ) , $cache   = 0);
}
else {


    // Extraction des données du fichier dans un tableau
    $data = csv_to_array($fichierListe, ' ');

    // suppression des lignes vides
    for ($n = 0; $n < count($data); $n++) {
        if (empty($data[$n]['taille'])) {
            array_splice($data, $n, 1);
        }
    }

    // recherche des sites de backup concernés
    $sites = array();
    for ($n = 0; $n < count($data); $n++) {
        $file = explode('-', $data[$n]['file']);
        $sites[] = $file[1];
    }
    $sites                = array_unique($sites);

    foreach ($sites as $site) {
        $nbBackup             = 0;
        $tailleTotale         = 0;
        $tailleMax            = '';
        $tailleMin            = '';
        $backupToday          = 0;
        $tailleFirstBackup	  = 0;
        $tailleLastBackup	  = 0;
        $timestampFirstBackup = '';
        $timestampLastBackup  = '';

            for ($n = 0; $n < count($data); $n++) {
                $file = explode('-', str_replace('_', '-', $data[$n]['file']));
                if ($site == $file[1]) {
                    $taille = round($data[$n]['taille'] / 1024 / 1024);
                    $jeedom = $file[1];
                    $version = $file[2];

                    $nbBackup++;
                    $tailleTotale += $taille;
                    if ($taille > $tailleMax || empty($tailleMax)) $tailleMax = $taille;
                    if ($taille < $tailleMin || empty($tailleMin)) $tailleMin = $taille;

                    // date des backups
                    $timestampBackup = mktime(0, 0, 0, $file[4], $file[5], $file[3]); // timestamp du backup à 0:00
                    $timestampNow = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
                    if ($timestampBackup == $timestampNow) $backupToday = 1;
                    if ($timestampBackup <= $timestampFirstBackup || empty($timestampFirstBackup)) {
                        $timestampFirstBackup = $timestampBackup;
                        $tailleFirstBackup = $taille;
                    }
                    if ($timestampBackup >= $timestampLastBackup || empty($timestampLastBackup)) {
                        $timestampLastBackup = $timestampBackup;
                        $tailleLastBackup = $taille;
                    }
                }
            }

            $scenario->setLog('| Résumé : ' . $site . ' (Version : ' . $version . ')');
            $scenario->setLog('|     Nb backup presents   : ' . $nbBackup);
            $scenario->setLog('|     1er backup dispo     : ' . date('d/m/Y', $timestampFirstBackup).' ('.$tailleFirstBackup.'Mo)');
            $scenario->setLog('|     dernier backup dispo : ' . date('d/m/Y', $timestampLastBackup).' ('.$tailleLastBackup.'Mo)');
            $scenario->setLog('|     Taille moyenne       : ' . round($tailleTotale / $nbBackup) . 'Mo');

        // gestion des erreurs
        if ($tailleMax >= $seuilTailleMax || $tailleMin <= $seuilTailleMin) {
                $scenario->setLog('| /!\ Pb de taille sur un backup - merci de verifier (taille min : ' . $tailleMin . 'Mo, max :' . $tailleMax . 'Mo)');
                if ($AlerteCentreMsg) message::add('Backup', $site . ' - Pb de taille sur une sauvegarde - merci de verifier (taille min : ' . $tailleMin . 'Mo, max :' . $tailleMax . 'Mo)');
                if ($AlerteNotifJC) $cmdNotifJC->execCmd($options = array(
                    'title'         => 'title=Defaut BACKUP ' . $site,
                    'message'       => 'Pb de taille sur un backup<br>Taille min : ' . $tailleMin . 'Mo<br>Taille max :' . $tailleMax . 'Mo'
                ) , $cache   = 0);

        }
        if ( !$backupToday) {
            $scenario->setLog('| /!\ Pas de backup aujourd\'hui');
            if ($AlerteCentreMsg) message::add('Backup', $site . ' - Pas de backup aujourd\'hui, dernier backup : ' . date('d/m/Y', $timestampLastBackup));
            if ($AlerteNotifJC) $cmdNotifJC->execCmd($options = array(
                'title'         => 'title=Defaut BACKUP ' . $site,
                'message'       => 'Pas de backup aujourd\'hui<br>Dernier backup : ' . date('d/m/Y', $timestampLastBackup)
            ) , $cache   = 0);
        }
    }
}

$scenario->setLog('└───────────────────────────');


Peut-être redonner une version propre et fonctionnelle à jour dans le post initial :blush:?

++

Je ne sais pas si cela a été évoqué dans les posts précédents et comme le message initial contient toujours l’erreur alors je me permets de vous transmettre cette info.

Toutes les lignes du style $data[$n][taille] ou ligne au lieu de taille renvoi une erreur depuis le passage en php 8, pour eviter cette erreur il faut corriger toutes les lignes avec $data[$n]['taille']

1 « J'aime »

Bonjour,

Il faut également faire la même chose pour tous les $data[$n][file] qu’il faut transformer en $data[$n]['file'] en PHP8.

@Noyax37 @Madcow, les erreurs liées à php8 sont normalement corrigées dans le post initial (pas testé !)
Merci pour votre retour

2 « J'aime »