diff --git a/Containers/mastercontainer/cron.sh b/Containers/mastercontainer/cron.sh
index 60fd4f2c..fc8c4081 100644
--- a/Containers/mastercontainer/cron.sh
+++ b/Containers/mastercontainer/cron.sh
@@ -12,6 +12,11 @@ while true; do
export AUTOMATIC_UPDATES=0
export START_CONTAINERS=1
fi
+ if [ "$(sed -n '3p' "/mnt/docker-aio-config/data/daily_backup_time")" != 'successNotificationsAreNotEnabled' ]; then
+ export SEND_SUCCESS_NOTIFICATIONS=1
+ else
+ export SEND_SUCCESS_NOTIFICATIONS=0
+ fi
set +x
if [ -f "/mnt/docker-aio-config/data/daily_backup_running" ]; then
export LOCK_FILE_PRESENT=1
diff --git a/Containers/mastercontainer/daily-backup.sh b/Containers/mastercontainer/daily-backup.sh
index f87b3966..62911b9c 100644
--- a/Containers/mastercontainer/daily-backup.sh
+++ b/Containers/mastercontainer/daily-backup.sh
@@ -105,7 +105,7 @@ if [ "$DAILY_BACKUP" = 1 ] && ([ "$AUTOMATIC_UPDATES" = 1 ] || [ "$START_CONTAIN
done
fi
echo "Sending backup notification..."
- sudo -u www-data php /var/www/docker-aio/php/src/Cron/BackupNotification.php
+ sudo -E -u www-data php /var/www/docker-aio/php/src/Cron/BackupNotification.php
fi
echo "Daily backup script has finished"
diff --git a/php/src/Controller/ConfigurationController.php b/php/src/Controller/ConfigurationController.php
index b7271398..e786697a 100644
--- a/php/src/Controller/ConfigurationController.php
+++ b/php/src/Controller/ConfigurationController.php
@@ -49,8 +49,13 @@ class ConfigurationController
} else {
$enableAutomaticUpdates = false;
}
+ if (isset($request->getParsedBody()['success_notification'])) {
+ $successNotification = true;
+ } else {
+ $successNotification = false;
+ }
$dailyBackupTime = $request->getParsedBody()['daily_backup_time'] ?? '';
- $this->configurationManager->SetDailyBackupTime($dailyBackupTime, $enableAutomaticUpdates);
+ $this->configurationManager->SetDailyBackupTime($dailyBackupTime, $enableAutomaticUpdates, $successNotification);
}
if (isset($request->getParsedBody()['delete_daily_backup_time'])) {
diff --git a/php/src/Cron/BackupNotification.php b/php/src/Cron/BackupNotification.php
index a570031b..17da93b2 100644
--- a/php/src/Cron/BackupNotification.php
+++ b/php/src/Cron/BackupNotification.php
@@ -21,7 +21,11 @@ $nextcloudContainer = $containerDefinitionFetcher->GetContainerById($id);
$backupExitCode = $dockerActionManger->GetBackupcontainerExitCode();
if ($backupExitCode === 0) {
- $dockerActionManger->sendNotification($nextcloudContainer, 'Daily backup successful!', 'You can get further info by looking at the backup logs in the AIO interface.');
+ 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) {
diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php
index 5bb295b5..7411cafc 100644
--- a/php/src/Data/ConfigurationManager.php
+++ b/php/src/Data/ConfigurationManager.php
@@ -676,7 +676,7 @@ class ConfigurationManager
/**
* @throws InvalidSettingConfigurationException
*/
- public function SetDailyBackupTime(string $time, bool $enableAutomaticUpdates) : void {
+ public function SetDailyBackupTime(string $time, bool $enableAutomaticUpdates, bool $successNotification) : void {
if ($time === "") {
throw new InvalidSettingConfigurationException("The daily backup time must not be empty!");
}
@@ -688,6 +688,9 @@ class ConfigurationManager
if ($enableAutomaticUpdates === false) {
$time .= PHP_EOL . 'automaticUpdatesAreNotEnabled';
}
+ if ($successNotification === false) {
+ $time .= PHP_EOL . 'successNotificationsAreNotEnabled';
+ }
file_put_contents(DataConst::GetDailyBackupTimeFile(), $time);
}
diff --git a/php/templates/containers.twig b/php/templates/containers.twig
index 40e2e9ea..b63953f6 100644
--- a/php/templates/containers.twig
+++ b/php/templates/containers.twig
@@ -481,6 +481,7 @@
+
{% else %}
Daily backups will be created at {{ daily_backup_time }} UTC which includes a notification about the result of the backup.