diff --git a/docker-compose.yml b/docker-compose.yml index df03f2c3..000cdde7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,7 @@ services: # - NEXTCLOUD_DATADIR=/mnt/ncdata # Allows to set the host directory for Nextcloud's datadir. See https://github.com/nextcloud/all-in-one#how-to-change-the-default-location-of-nextclouds-datadir # - NEXTCLOUD_MOUNT=/mnt/ # Allows the Nextcloud container to access the chosen directory on the host. See https://github.com/nextcloud/all-in-one#how-to-allow-the-nextcloud-container-to-access-directories-on-the-host # - DOCKER_SOCKET_PATH=/var/run/docker.sock # Needs to be specified if the docker socket on the host is not located in the default '/var/run/docker.sock'. Otherwise mastercontainer updates will fail. + # - DISABLE_BACKUP_SECTION=true # Setting this to true allows to hide the backup section in the AIO interface. # # Optional: Caddy reverse proxy. See https://github.com/nextcloud/all-in-one/blob/main/reverse-proxy.md # # You can find further examples here: https://github.com/nextcloud/all-in-one/discussions/588 diff --git a/php/public/index.php b/php/public/index.php index 2a483da9..cc29d0a1 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -101,6 +101,7 @@ $app->get('/containers', function ($request, $response, $args) use ($container) 'talk_port' => $configurationManager->GetTalkPort(), 'collabora_dictionaries' => $configurationManager->GetCollaboraDictionaries(), 'automatic_updates' => $configurationManager->areAutomaticUpdatesEnabled(), + 'is_backup_section_enabled' => $configurationManager->isBackupSectionEnabled(), ]); })->setName('profile'); $app->get('/login', function ($request, $response, $args) use ($container) { diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index 8604c4f8..67ab009d 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -624,4 +624,19 @@ class ConfigurationManager $defaultValue = ''; return $this->GetEnvironmentalVariableOrConfig($envVariableName, $configName, $defaultValue); } + + private function GetDisableBackupSection() : string { + $envVariableName = 'DISABLE_BACKUP_SECTION'; + $configName = 'disable_backup_section'; + $defaultValue = ''; + return $this->GetEnvironmentalVariableOrConfig($envVariableName, $configName, $defaultValue); + } + + public function isBackupSectionEnabled() : bool { + if ($this->GetDisableBackupSection() === 'true') { + return false; + } else { + return true; + } + } } diff --git a/php/templates/containers.twig b/php/templates/containers.twig index 281ef914..4da1ccb1 100644 --- a/php/templates/containers.twig +++ b/php/templates/containers.twig @@ -293,117 +293,125 @@ {% if was_start_button_clicked == true %} - {% if is_backup_container_running == false and borg_backup_host_location == "" and isApacheStarting != true %} + {% if is_backup_section_enabled == false %}

Backup and restore

- Please type in the directory where backups will get created on the host system:

-
- - - - -
+ The backup section is disabled via environmental variable.

+ {% else %} + {% if is_backup_container_running == false and borg_backup_host_location == "" and isApacheStarting != true %} +

Backup and restore

+ Please type in the directory where backups will get created on the host system:

+
+ + + + +
The folder path that you enter must start with / and must not end with /.

An example for Linux is /mnt/backup.
For macOS it may be /var/backup.
On Windows it must be nextcloud_aio_backupdir. You need to create the 'nextcloud_aio_backupdir' volume beforehand by following this documentation: click here

+ {% endif %} {% endif %} - {% if borg_backup_host_location != "" %} - {% if is_backup_container_running == false %} -

Backup and restore

- {% if backup_exit_code > 0 %} - Last {{ borg_backup_mode }} failed! (Logs)

- {% 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.

-
- - - - -
- {% endif %} - {% elseif backup_exit_code == 0 %} - {% if borg_backup_mode == "backup" %} - Last {{ borg_backup_mode }} successful on {{ last_backup_time }} UTC! (Logs)

- {% else %} - Last {{ borg_backup_mode }} successful! (Logs)

- {% endif %} - {% endif %} - {% endif %} + {% if is_backup_section_enabled == true %} - {% if is_backup_container_running == false and isApacheStarting == false %} - {% if has_backup_run_once == true %} -
- Click here to reveal all backup options (it also includes an option for automatic updates)
- {% endif %} -

Backup information

- This is your encryption password for backups: {{ borgbackup_password }}

- Please save it at a safe place since you won't be able to restore from backup if you loose this password!

- Backed up will get all important data of your Nextcloud AIO instance like the database, your files and configuration files of the mastercontainer and else.

- The backup itself will use a tool that is called BorgBackup which is a well-known server backup tool that efficiently backs up your files and encrypts them on the fly.

- Backups get created in the following directory on the host: {{ borg_backup_host_location }}/borg

- Be aware that this solution does not back up files and folders that are mounted into Nextcloud using the external storage app. - - {% if isApacheStarting != true %} -

Backup creation

- Clicking on the button below will create a backup.

-
- - - -
- - {% if has_backup_run_once == true %} -

Backup check

- Click on the button below to perform a backup integrity check. This is an option that verifies that your backup is intact but it should't be needed in most situtations.

-
- - -
-
- -

Backup restore

- Choose the backup that you want to restore and click on the button below to restore the selected backup. This will overwrite all your files with the state of the backup so you should consider creating a backup first. It also makes sense to run an integrity check before restoring your files but is not mandatory since it shouldn't be needed in most situations.

-
- - - - -
- -

Daily backup and automatic updates

- {% if daily_backup_time == "" %} - By entering a time below, you can enable daily backups. It will create them at the entered time in 24h format. E.g. 04:00 will create backups at 4 am UTC and 16:00 at 4 pm UTC.

+ {% if borg_backup_host_location != "" %} + {% if is_backup_container_running == false %} +

Backup and restore

+ {% if backup_exit_code > 0 %} + Last {{ borg_backup_mode }} failed! (
Logs)

+ {% 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.

- + -
-
+
+ {% endif %} + {% elseif backup_exit_code == 0 %} + {% if borg_backup_mode == "backup" %} + Last {{ borg_backup_mode }} successful on {{ last_backup_time }} UTC! (Logs)

{% else %} - Daily backups will be created at {{ daily_backup_time }} UTC which includes a notification about the result of the backup. - {% if automatic_updates == true %} - Also your containers, the mastercontainer and on saturdays your Nextcloud apps will be automatically updated. - {% endif %} - You can disable this option again by clicking on the button below.

-
- - - - -
+ Last {{ borg_backup_mode }} successful! (Logs)

{% endif %} {% endif %} {% endif %} - {% if has_backup_run_once == false %} -

- {% else %} -


+ + {% if is_backup_container_running == false and isApacheStarting == false %} + {% if has_backup_run_once == true %} +
+ Click here to reveal all backup options (it also includes an option for automatic updates)
+ {% endif %} +

Backup information

+ This is your encryption password for backups: {{ borgbackup_password }}

+ Please save it at a safe place since you won't be able to restore from backup if you loose this password!

+ Backed up will get all important data of your Nextcloud AIO instance like the database, your files and configuration files of the mastercontainer and else.

+ The backup itself will use a tool that is called BorgBackup which is a well-known server backup tool that efficiently backs up your files and encrypts them on the fly.

+ Backups get created in the following directory on the host: {{ borg_backup_host_location }}/borg

+ Be aware that this solution does not back up files and folders that are mounted into Nextcloud using the external storage app. + + {% if isApacheStarting != true %} +

Backup creation

+ Clicking on the button below will create a backup.

+
+ + + +
+ + {% if has_backup_run_once == true %} +

Backup check

+ Click on the button below to perform a backup integrity check. This is an option that verifies that your backup is intact but it should't be needed in most situtations.

+
+ + +
+
+ +

Backup restore

+ Choose the backup that you want to restore and click on the button below to restore the selected backup. This will overwrite all your files with the state of the backup so you should consider creating a backup first. It also makes sense to run an integrity check before restoring your files but is not mandatory since it shouldn't be needed in most situations.

+
+ + + + +
+ +

Daily backup and automatic updates

+ {% if daily_backup_time == "" %} + By entering a time below, you can enable daily backups. It will create them at the entered time in 24h format. E.g. 04:00 will create backups at 4 am UTC and 16:00 at 4 pm UTC.

+
+ + + +
+
+
+ {% else %} + Daily backups will be created at {{ daily_backup_time }} UTC which includes a notification about the result of the backup. + {% if automatic_updates == true %} + Also your containers, the mastercontainer and on saturdays your Nextcloud apps will be automatically updated. + {% endif %} + You can disable this option again by clicking on the button below.

+
+ + + + +
+ {% endif %} + {% endif %} + {% endif %} + {% if has_backup_run_once == false %} +

+ {% else %} +


+ {% endif %} {% endif %} {% endif %} {% endif %} diff --git a/readme.md b/readme.md index 5ecaca76..439427df 100644 --- a/readme.md +++ b/readme.md @@ -377,6 +377,9 @@ You can do so by running the `/daily-backup.sh` script that is stored in the mas One example for this would be `sudo docker exec -it nextcloud-aio-mastercontainer DAILY_BACKUP=1 /daily-backup.sh`, which you can run via a cronjob or put it in a script. +### How to disable the backup section? +If you already have a backup solution in place, you may want to hide the backup section. You can do so by adding `-e DISABLE_BACKUP_SECTION=true` to the initial startup of the mastercontainer. + ### How to change the default location of Nextcloud's Datadir? You can configure the Nextcloud container to use a specific directory on your host as data directory. You can do so by adding the environmental variable `NEXTCLOUD_DATADIR` to the initial startup of the mastercontainer. Allowed values for that variable are strings that start with `/` and are not equal to `/`. diff --git a/tests/QA/060-environmental-variables.md b/tests/QA/060-environmental-variables.md index 69625f9a..94321459 100644 --- a/tests/QA/060-environmental-variables.md +++ b/tests/QA/060-environmental-variables.md @@ -8,5 +8,6 @@ - [ ] When starting the mastercontainer with `-e NEXTCLOUD_DATADIR="/mnt/testdata"` it should map that location from `/mnt/testdata` to `/mnt/ncdata` inside the Nextcloud container. Not having adjusted the permissions correctly before starting the Nextcloud container the first time will not allow the Nextcloud container to start correctly. See https://github.com/nextcloud/all-in-one#how-to-change-the-default-location-of-nextclouds-datadir for allowed values. - [ ] When starting the mastercontainer with `-e NEXTCLOUD_MOUNT="/mnt/"` it should map `/mnt/` to `/mnt/` inside the Nextcloud container. See https://github.com/nextcloud/all-in-one#how-to-allow-the-nextcloud-container-to-access-directories-on-the-host for allowed values. - [ ] When starting the mastercontainer with `-e DOCKER_SOCKET_PATH="/var/run/docker.sock.raw"` it should map `/var/run/docker.sock.raw` to `/var/run/docker.sock` inside the watchtower container which allow to update the mastercontainer on macos and with docker rootless. +- [ ] When starting the mastercontainer with `-e DISABLE_BACKUP_SECTION=true` it should hide the backup section that gets shown after AIO is set up (everything of [020-backup-and-restore](./020-backup-and-restore.md)) and simply show that the backup section is disabled. You can now continue with [070-timezone-change.md](./070-timezone-change.md)