diff --git a/Containers/mastercontainer/cron.sh b/Containers/mastercontainer/cron.sh
index 60fd4f2c0bc0..fc8c40819228 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 f87b3966215e..62911b9c628f 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 b7271398fa03..e786697ae881 100644
--- a/php/src/Controller/ConfigurationController.php
+++ b/php/src/Controller/ConfigurationController.php
@@ -49,8 +49,13 @@ public function SetConfig(Request $request, Response $response, array $args) : R
} 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 a570031b4082..1eccf667426f 100644
--- a/php/src/Cron/BackupNotification.php
+++ b/php/src/Cron/BackupNotification.php
@@ -21,7 +21,11 @@
$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') === "1") {
+ $dockerActionManger->sendNotification($nextcloudContainer, 'Daily backup successful!', 'You can get further info by looking at the backup logs in the AIO interface.');
+ } else {
+ 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.");
+ }
}
if ($backupExitCode > 0) {
diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php
index 5bb295b5f262..7411cafc12e7 100644
--- a/php/src/Data/ConfigurationManager.php
+++ b/php/src/Data/ConfigurationManager.php
@@ -676,7 +676,7 @@ private function GetCollaboraSeccompDisabledState() : string {
/**
* @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 @@ public function SetDailyBackupTime(string $time, bool $enableAutomaticUpdates) :
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 40e2e9eace74..b63953f6e673 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.