all-in-one/php/src/Cron/BackupNotification.php
Simon L 258f6683de daily backup - allow to disable succesful backup notifications
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-10-10 12:12:11 +02:00

33 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
// increase memory limit to 2GB
ini_set('memory_limit', '2048M');
use DI\Container;
require __DIR__ . '/../../vendor/autoload.php';
$container = \AIO\DependencyInjection::GetContainer();
/** @var \AIO\Docker\DockerActionManager $dockerActionManger */
$dockerActionManger = $container->get(\AIO\Docker\DockerActionManager::class);
/** @var \AIO\ContainerDefinitionFetcher $containerDefinitionFetcher */
$containerDefinitionFetcher = $container->get(\AIO\ContainerDefinitionFetcher::class);
$id = 'nextcloud-aio-nextcloud';
$nextcloudContainer = $containerDefinitionFetcher->GetContainerById($id);
$backupExitCode = $dockerActionManger->GetBackupcontainerExitCode();
if ($backupExitCode === 0) {
if (getenv('SEND_SUCCESS_NOTIFICATIONS') === "0") {
error_log("Daily backup successful! Only logging successful backup and not sending backup notification since that has been disabled! You can get further info by looking at the backup logs in the AIO interface.");
} else {
$dockerActionManger->sendNotification($nextcloudContainer, 'Daily backup successful!', 'You can get further info by looking at the backup logs in the AIO interface.');
}
}
if ($backupExitCode > 0) {
$dockerActionManger->sendNotification($nextcloudContainer, 'Daily backup failed!', 'You can get further info by looking at the backup logs in the AIO interface.');
}