diff --git a/Containers/borgbackup/backupscript.sh b/Containers/borgbackup/backupscript.sh
index 42a32b59..069a9e14 100644
--- a/Containers/borgbackup/backupscript.sh
+++ b/Containers/borgbackup/backupscript.sh
@@ -364,6 +364,23 @@ if [ "$BORG_MODE" = check ]; then
exit 0
fi
+# Do the Backup check-repair
+if [ "$BORG_MODE" = "check-repair" ]; then
+ get_start_time
+ echo "Checking the backup integrity and repairing it..."
+
+ # Perform the check-repair
+ if ! borg check -v --repair "$BORG_BACKUP_DIRECTORY"; then
+ echo "Some errors were found while checking and repairing the backup integrity!"
+ exit 1
+ fi
+
+ # Inform user
+ get_expiration_time
+ echo "Check finished successfully on $END_DATE_READABLE ($DURATION_READABLE)"
+ exit 0
+fi
+
# Do the backup test
if [ "$BORG_MODE" = test ]; then
if ! [ -d "$BORG_BACKUP_DIRECTORY" ]; then
diff --git a/Containers/borgbackup/start.sh b/Containers/borgbackup/start.sh
index 00e06ed4..e8d93f58 100644
--- a/Containers/borgbackup/start.sh
+++ b/Containers/borgbackup/start.sh
@@ -20,7 +20,7 @@ export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
# Validate BORG_MODE
-if [ "$BORG_MODE" != backup ] && [ "$BORG_MODE" != restore ] && [ "$BORG_MODE" != check ] && [ "$BORG_MODE" != test ]; then
+if [ "$BORG_MODE" != backup ] && [ "$BORG_MODE" != restore ] && [ "$BORG_MODE" != check ] && [ "$BORG_MODE" != "check-repair" ] && [ "$BORG_MODE" != test ]; then
echo "No correct BORG_MODE mode applied. Valid are 'backup', 'check', 'restore' and 'test'."
exit 1
fi
diff --git a/php/public/index.php b/php/public/index.php
index b8f48ce9..be87258d 100644
--- a/php/public/index.php
+++ b/php/public/index.php
@@ -57,6 +57,7 @@ $app->get('/api/docker/getwatchtower', AIO\Controller\DockerController::class .
$app->post('/api/docker/start', AIO\Controller\DockerController::class . ':StartContainer');
$app->post('/api/docker/backup', AIO\Controller\DockerController::class . ':StartBackupContainerBackup');
$app->post('/api/docker/backup-check', AIO\Controller\DockerController::class . ':StartBackupContainerCheck');
+$app->post('/api/docker/backup-check-repair', AIO\Controller\DockerController::class . ':StartBackupContainerCheckRepair');
$app->post('/api/docker/backup-test', AIO\Controller\DockerController::class . ':StartBackupContainerTest');
$app->post('/api/docker/restore', AIO\Controller\DockerController::class . ':StartBackupContainerRestore');
$app->post('/api/docker/stop', AIO\Controller\DockerController::class . ':StopContainer');
diff --git a/php/src/Controller/DockerController.php b/php/src/Controller/DockerController.php
index 979edbc8..dd417b27 100644
--- a/php/src/Controller/DockerController.php
+++ b/php/src/Controller/DockerController.php
@@ -113,6 +113,22 @@ class DockerController
return $response->withStatus(201)->withHeader('Location', '/');
}
+ public function StartBackupContainerCheckRepair(Request $request, Response $response, array $args) : Response {
+ $config = $this->configurationManager->GetConfig();
+ $config['backup-mode'] = 'check-repair';
+ $this->configurationManager->WriteConfig($config);
+
+ $id = 'nextcloud-aio-borgbackup';
+ $this->PerformRecursiveContainerStart($id);
+
+ // Restore to backup check which is needed to make the UI logic work correctly
+ $config = $this->configurationManager->GetConfig();
+ $config['backup-mode'] = 'check';
+ $this->configurationManager->WriteConfig($config);
+
+ return $response->withStatus(201)->withHeader('Location', '/');
+ }
+
public function StartBackupContainerTest(Request $request, Response $response, array $args) : Response {
$config = $this->configurationManager->GetConfig();
$config['backup-mode'] = 'test';
diff --git a/php/templates/containers.twig b/php/templates/containers.twig
index 90989315..dbc07e12 100644
--- a/php/templates/containers.twig
+++ b/php/templates/containers.twig
@@ -111,7 +111,16 @@
{% if borg_backup_mode == 'test' %}
Please adjust the path and/or the password in order to make it work!
{% elseif borg_backup_mode == 'check' %}
- The backup archive seems to be corrupt. Please try to use a different intact backup archive or try to fix it by following this documentation
+ The backup archive seems to be corrupt. Please try to use a different intact backup archive or try to fix it by following this documentation
+
+ Reveal repair option
+ Below is the option to repair the integrity of your backup. Please note: Please only use this after you have read the documentation above! (It will run the command 'borg check --repair' for you.)
+
+
{% endif %}
{% elseif backup_exit_code == 0 %}
Last {{ borg_backup_mode }} successful! (Logs)
@@ -329,7 +338,16 @@
{% if backup_exit_code > 0 %}
Last {{ borg_backup_mode }} failed! (Logs)
{% if borg_backup_mode == "check" %}
- The backup archive seems to be corrupt. You can try to fix it by following this documentation
+ The backup check was not successful which might points towards a corrupt archive (look at the logs). If that should be the case, you can try to fix it by following this documentation
+
+ Reveal repair option
+ Below is the option to repair the integrity of your backup. Please note: Please only use this after you have read the documentation above! (It will run the command 'borg check --repair' for you.)
+
+
{% endif %}
{% if has_backup_run_once == false %}
You may change the backup path again since the initial backup was not successful. After submitting the new value, you need to click on 'Create Backup' for testing the new value.