Debug cron to send backup by email.
This commit is contained in:
parent
82244afb94
commit
7defe26e56
@ -1194,7 +1194,9 @@ class Utils
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$filepath = '';
|
||||
$output = '';
|
||||
$error = 0;
|
||||
|
||||
if (!empty($from)) {
|
||||
$from = dol_escape_htmltag($from);
|
||||
@ -1244,20 +1246,31 @@ class Utils
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($filepath) {
|
||||
if ($filesize > 100000000) {
|
||||
$output = 'Sorry, last backup file is too large to be send by email';
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
$output = 'No backup file found';
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
|
||||
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1);
|
||||
if ($mailfile->error) {
|
||||
$error++;
|
||||
} else {
|
||||
$result = $mailfile->sendfile();
|
||||
$output = $mailfile->error;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$result = $mailfile->sendfile();
|
||||
if ($result <= 0) {
|
||||
$error++;
|
||||
$output = $mailfile->error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ class modCron extends DolibarrModules
|
||||
$this->cronjobs = array(
|
||||
0=>array('entity'=>0, 'label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'tempfilesold+logfiles', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true),
|
||||
1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>in_array($this->db->type, array('mysql', 'mysqli'))),
|
||||
2=>array('entity'=>0, 'label'=>'MakeSendLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'sendDumpDatabase', 'parameters'=>',,,,,sql', 'comment'=>'MakeSendLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>604800, 'priority'=>91, 'status'=>0, 'test'=>'!empty($conf->global->MAIN_ALLOW_BACKUP_BY_EMAIL) && in_array($this->db->type, array(\'mysql\', \'mysqli\'))'),
|
||||
2=>array('entity'=>0, 'label'=>'MakeSendLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'sendDumpDatabase', 'parameters'=>',,,,,sql', 'comment'=>'MakeSendLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>604800, 'priority'=>91, 'status'=>0, 'test'=>'!empty($conf->global->MAIN_ALLOW_BACKUP_BY_EMAIL) && in_array($db->type, array(\'mysql\', \'mysqli\'))'),
|
||||
// 1=>array('entity'=>0, 'label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24)
|
||||
);
|
||||
|
||||
|
||||
@ -478,8 +478,12 @@ if ($num > 0) {
|
||||
if (empty($obj)) {
|
||||
break;
|
||||
}
|
||||
if (isset($obj->test) && !verifCond($obj->test)) {
|
||||
continue; // Discard line with test = false
|
||||
|
||||
if (isset($obj->test)) {
|
||||
$veriftest = verifCond($obj->test);
|
||||
if (!$veriftest) {
|
||||
continue; // Discard line with test = false
|
||||
}
|
||||
}
|
||||
|
||||
$object->id = $obj->rowid;
|
||||
|
||||
@ -83,7 +83,7 @@ JobDisabled=Job disabled
|
||||
MakeLocalDatabaseDumpShort=Local database backup
|
||||
MakeLocalDatabaseDump=Create a local database dump. Parameters are: compression ('gz' or 'bz' or 'none'), backup type ('mysql', 'pgsql', 'auto'), 1, 'auto' or filename to build, number of backup files to keep
|
||||
MakeSendLocalDatabaseDumpShort=Send local database backup
|
||||
MakeSendLocalDatabaseDump=Send local datebase backup to mail. Parameters are: to, from, subject, message, filename (Name of file sent), filter ('sql' for backup of database only)
|
||||
MakeSendLocalDatabaseDump=Send local database backup by email. Parameters are: to, from, subject, message, filename (Name of file sent), filter ('sql' for backup of database only)
|
||||
WarningCronDelayed=Attention, for performance purpose, whatever is next date of execution of enabled jobs, your jobs may be delayed to a maximum of %s hours, before being run.
|
||||
DATAPOLICYJob=Data cleaner and anonymizer
|
||||
JobXMustBeEnabled=Job %s must be enabled
|
||||
|
||||
Loading…
Reference in New Issue
Block a user