mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-20 22:46:55 +00:00
Merge pull request #1670 from nextcloud/enh/1537/repair-integrity
allow to repair the integrity of the backup archive
This commit is contained in:
commit
c0e22efdbc
5 changed files with 55 additions and 3 deletions
|
|
@ -364,6 +364,23 @@ if [ "$BORG_MODE" = check ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
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
|
# Do the backup test
|
||||||
if [ "$BORG_MODE" = test ]; then
|
if [ "$BORG_MODE" = test ]; then
|
||||||
if ! [ -d "$BORG_BACKUP_DIRECTORY" ]; then
|
if ! [ -d "$BORG_BACKUP_DIRECTORY" ]; then
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes
|
||||||
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
|
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
|
||||||
|
|
||||||
# Validate BORG_MODE
|
# 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'."
|
echo "No correct BORG_MODE mode applied. Valid are 'backup', 'check', 'restore' and 'test'."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -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/start', AIO\Controller\DockerController::class . ':StartContainer');
|
||||||
$app->post('/api/docker/backup', AIO\Controller\DockerController::class . ':StartBackupContainerBackup');
|
$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', 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/backup-test', AIO\Controller\DockerController::class . ':StartBackupContainerTest');
|
||||||
$app->post('/api/docker/restore', AIO\Controller\DockerController::class . ':StartBackupContainerRestore');
|
$app->post('/api/docker/restore', AIO\Controller\DockerController::class . ':StartBackupContainerRestore');
|
||||||
$app->post('/api/docker/stop', AIO\Controller\DockerController::class . ':StopContainer');
|
$app->post('/api/docker/stop', AIO\Controller\DockerController::class . ':StopContainer');
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,22 @@ class DockerController
|
||||||
return $response->withStatus(201)->withHeader('Location', '/');
|
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 {
|
public function StartBackupContainerTest(Request $request, Response $response, array $args) : Response {
|
||||||
$config = $this->configurationManager->GetConfig();
|
$config = $this->configurationManager->GetConfig();
|
||||||
$config['backup-mode'] = 'test';
|
$config['backup-mode'] = 'test';
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,16 @@
|
||||||
{% if borg_backup_mode == 'test' %}
|
{% if borg_backup_mode == 'test' %}
|
||||||
Please adjust the path and/or the password in order to make it work!<br><br>
|
Please adjust the path and/or the password in order to make it work!<br><br>
|
||||||
{% elseif borg_backup_mode == 'check' %}
|
{% 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 <a href="https://borgbackup.readthedocs.io/en/stable/faq.html#i-get-an-integrityerror-or-similar-what-now"><b>this documentation</b></a>
|
The backup archive seems to be corrupt. Please try to use a different intact backup archive or try to fix it by following <a href="https://borgbackup.readthedocs.io/en/stable/faq.html#i-get-an-integrityerror-or-similar-what-now"><b>this documentation</b></a><br><br>
|
||||||
|
<details>
|
||||||
|
<summary>Reveal repair option</summary><br />
|
||||||
|
Below is the option to repair the integrity of your backup. <b>Please note:</b> Please only use this after you have read the documentation above! (It will run the command 'borg check --repair' for you.)<br><br>
|
||||||
|
<form method="POST" action="/api/docker/backup-check-repair" class="xhr">
|
||||||
|
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
|
||||||
|
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
|
||||||
|
<input class="button" type="submit" value="Check and repair backup integrity" onclick="return confirm('Check and repair backup integrity? Are you sure that you want to check and repair the backup integrity? This should only be done after reading the mentioned documentation.')"/><br/>
|
||||||
|
</form>
|
||||||
|
</details><br /><br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elseif backup_exit_code == 0 %}
|
{% elseif backup_exit_code == 0 %}
|
||||||
<span class="status success"></span> Last {{ borg_backup_mode }} successful! (<a href="/api/docker/logs?id=nextcloud-aio-borgbackup">Logs</a>)<br /><br />
|
<span class="status success"></span> Last {{ borg_backup_mode }} successful! (<a href="/api/docker/logs?id=nextcloud-aio-borgbackup">Logs</a>)<br /><br />
|
||||||
|
|
@ -329,7 +338,16 @@
|
||||||
{% if backup_exit_code > 0 %}
|
{% if backup_exit_code > 0 %}
|
||||||
<span class="status error"></span> Last {{ borg_backup_mode }} failed! (<a href="/api/docker/logs?id=nextcloud-aio-borgbackup">Logs</a>)<br /><br />
|
<span class="status error"></span> Last {{ borg_backup_mode }} failed! (<a href="/api/docker/logs?id=nextcloud-aio-borgbackup">Logs</a>)<br /><br />
|
||||||
{% if borg_backup_mode == "check" %}
|
{% if borg_backup_mode == "check" %}
|
||||||
The backup archive seems to be corrupt. You can try to fix it by following <a href="https://borgbackup.readthedocs.io/en/stable/faq.html#i-get-an-integrityerror-or-similar-what-now"><b>this documentation</b></a><br /><br />
|
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 <a href="https://borgbackup.readthedocs.io/en/stable/faq.html#i-get-an-integrityerror-or-similar-what-now"><b>this documentation</b></a><br /><br />
|
||||||
|
<details>
|
||||||
|
<summary>Reveal repair option</summary><br />
|
||||||
|
Below is the option to repair the integrity of your backup. <b>Please note:</b> Please only use this after you have read the documentation above! (It will run the command 'borg check --repair' for you.)<br><br>
|
||||||
|
<form method="POST" action="/api/docker/backup-check-repair" class="xhr">
|
||||||
|
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
|
||||||
|
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
|
||||||
|
<input class="button" type="submit" value="Check and repair backup integrity" onclick="return confirm('Check and repair backup integrity? Are you sure that you want to check and repair the backup integrity? This should only be done after reading the mentioned documentation.')"/><br/>
|
||||||
|
</form>
|
||||||
|
</details><br /><br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if has_backup_run_once == false %}
|
{% 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.<br /><br />
|
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.<br /><br />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue