mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-02-27 15:25:40 +08:00
Merge pull request #2428 from nextcloud/enh/noid/borg-retention-policy
allow to adjust borgs retention policy
This commit is contained in:
commit
ef43d19a27
9 changed files with 24 additions and 8 deletions
|
@ -18,3 +18,4 @@ COPY --chmod=770 *.sh /
|
|||
ENTRYPOINT ["/start.sh"]
|
||||
|
||||
LABEL com.centurylinklabs.watchtower.monitor-only="true"
|
||||
ENV BORG_RETENTION_POLICY="--keep-within=7d --keep-weekly=4 --keep-monthly=6"
|
||||
|
|
|
@ -167,11 +167,13 @@ if [ "$BORG_MODE" = backup ]; then
|
|||
rm -f "/nextcloud_aio_volumes/nextcloud_aio_nextcloud_data/skip.update"
|
||||
|
||||
# Prune options
|
||||
BORG_PRUNE_OPTS=(--stats --keep-within=7d --keep-weekly=4 --keep-monthly=6 "$BORG_BACKUP_DIRECTORY")
|
||||
set -x
|
||||
read -ra BORG_PRUNE_OPTS <<< "$BORG_RETENTION_POLICY"
|
||||
set +x
|
||||
|
||||
# Prune archives
|
||||
echo "Pruning the archives..."
|
||||
if ! borg prune --glob-archives '*_*-nextcloud-aio' "${BORG_PRUNE_OPTS[@]}"; then
|
||||
if ! borg prune --stats --glob-archives '*_*-nextcloud-aio' "${BORG_PRUNE_OPTS[@]}" "$BORG_BACKUP_DIRECTORY"; then
|
||||
echo "Failed to prune archives!"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -202,7 +204,7 @@ if [ "$BORG_MODE" = backup ]; then
|
|||
exit 1
|
||||
fi
|
||||
echo "Pruning additional volumes..."
|
||||
if ! borg prune --glob-archives '*_*-additional-docker-volumes' "${BORG_PRUNE_OPTS[@]}"; then
|
||||
if ! borg prune --stats --glob-archives '*_*-additional-docker-volumes' "${BORG_PRUNE_OPTS[@]}" "$BORG_BACKUP_DIRECTORY"; then
|
||||
echo "Failed to prune additional docker-volumes archives!"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -232,7 +234,7 @@ if [ "$BORG_MODE" = backup ]; then
|
|||
exit 1
|
||||
fi
|
||||
echo "Pruning additional host mounts..."
|
||||
if ! borg prune --glob-archives '*_*-additional-host-mounts' "${BORG_PRUNE_OPTS[@]}"; then
|
||||
if ! borg prune --stats --glob-archives '*_*-additional-host-mounts' "${BORG_PRUNE_OPTS[@]}" "$BORG_BACKUP_DIRECTORY"; then
|
||||
echo "Failed to prune additional host-mount archives!"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -20,6 +20,7 @@ services:
|
|||
# - AIO_DISABLE_BACKUP_SECTION=false # Setting this to true allows to hide the backup section in the AIO interface.
|
||||
# - APACHE_PORT=11000 # Is needed when running behind a web server or reverse proxy (like Apache, Nginx and else). See https://github.com/nextcloud/all-in-one/blob/main/reverse-proxy.md
|
||||
# - APACHE_IP_BINDING=127.0.0.1 # Should be set when running behind a web server or reverse proxy (like Apache, Nginx and else) that is running on the same host. See https://github.com/nextcloud/all-in-one/blob/main/reverse-proxy.md
|
||||
# - BORG_RETENTION_POLICY=--keep-within=7d --keep-weekly=4 --keep-monthly=6 # Allows to adjust borgs retention policy. See https://github.com/nextcloud/all-in-one#how-to-adjust-borgs-retention-policy
|
||||
# - COLLABORA_SECCOMP_DISABLED=false # Setting this to true allows to disable Collabora's Seccomp feature. See https://github.com/nextcloud/all-in-one#how-to-disable-collaboras-seccomp-feature
|
||||
# - 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
|
||||
|
|
|
@ -273,7 +273,8 @@
|
|||
"BACKUP_RESTORE_PASSWORD=%BACKUP_RESTORE_PASSWORD%",
|
||||
"ADDITIONAL_DIRECTORIES_BACKUP=%ADDITIONAL_DIRECTORIES_BACKUP%",
|
||||
"BORGBACKUP_HOST_LOCATION=%BORGBACKUP_HOST_LOCATION%",
|
||||
"BORG_HOST_ID=nextcloud-aio-borgbackup"
|
||||
"BORG_HOST_ID=nextcloud-aio-borgbackup",
|
||||
"BORG_RETENTION_POLICY=%BORG_RETENTION_POLICY%"
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
|
|
|
@ -581,6 +581,13 @@ class ConfigurationManager
|
|||
return $this->GetEnvironmentalVariableOrConfig($envVariableName, $configName, $defaultValue);
|
||||
}
|
||||
|
||||
public function GetBorgRetentionPolicy() : string {
|
||||
$envVariableName = 'BORG_RETENTION_POLICY';
|
||||
$configName = 'borg_retention_policy';
|
||||
$defaultValue = '--keep-within=7d --keep-weekly=4 --keep-monthly=6';
|
||||
return $this->GetEnvironmentalVariableOrConfig($envVariableName, $configName, $defaultValue);
|
||||
}
|
||||
|
||||
public function GetDockerSocketPath() : string {
|
||||
$envVariableName = 'WATCHTOWER_DOCKER_SOCKET_PATH';
|
||||
$configName = 'docker_socket_path';
|
||||
|
|
|
@ -328,6 +328,8 @@ class DockerActionManager
|
|||
$replacements[1] = $this->configurationManager->GetNextcloudMemoryLimit();
|
||||
} elseif ($out[1] === 'NEXTCLOUD_MAX_TIME') {
|
||||
$replacements[1] = $this->configurationManager->GetNextcloudMaxTime();
|
||||
} elseif ($out[1] === 'BORG_RETENTION_POLICY') {
|
||||
$replacements[1] = $this->configurationManager->GetBorgRetentionPolicy();
|
||||
} elseif ($out[1] === 'NEXTCLOUD_TRUSTED_CACERTS_DIR') {
|
||||
$replacements[1] = $this->configurationManager->GetTrustedCacertsDir();
|
||||
} elseif ($out[1] === 'ADDITIONAL_DIRECTORIES_BACKUP') {
|
||||
|
|
|
@ -407,7 +407,7 @@
|
|||
The backup itself uses a tool that is called <a href="https://github.com/borgbackup/borg#what-is-borgbackup"><b>BorgBackup</b></a> which is a well-known server backup tool that efficiently backs up your files and encrypts them on the fly. <br /><br/>
|
||||
Backups get created in the following directory on the host: <b>{{ borg_backup_host_location }}/borg</b> <br /><br/>
|
||||
Be aware that this solution does not back up files and folders that are mounted into Nextcloud using the external storage app - but you can add further Docker volumes and host paths that you want to back up after the initial backup is done.<br><br>
|
||||
Regarding backup retention, see <b><a href="https://github.com/nextcloud/all-in-one/discussions/1675">this</a></b>.<br><br>
|
||||
Regarding backup retention, see <b><a href="https://github.com/nextcloud/all-in-one#how-to-adjust-borgs-retention-policy">this</a></b>.<br><br>
|
||||
Daily backups can get enabled after the initial backup is done. Enabling this also allows to enable an option that allows to update all containers, Nextcloud and its apps automatically.<br><br>
|
||||
For further documentation and options on this backup solution refer to <b><a href="https://github.com/nextcloud/all-in-one#backup-solution">this section</a></b> and below.<br>
|
||||
|
||||
|
|
|
@ -343,10 +343,11 @@ Daily backups can get enabled after the initial backup is done. Enabling this al
|
|||
|
||||
Be aware that this solution does not back up files and folders that are mounted into Nextcloud using the external storage app - but you can add further Docker volumes and host paths that you want to back up after the initial backup is done.
|
||||
|
||||
Regarding backup retention, see [this documentation](https://github.com/nextcloud/all-in-one/discussions/1675).
|
||||
|
||||
---
|
||||
|
||||
#### How to adjust borgs retention policy?
|
||||
The built-in borg-based backup solution has by default a retention policy of `--keep-within=7d --keep-weekly=4 --keep-monthly=6`. See https://borgbackup.readthedocs.io/en/stable/usage/prune.html for what these values mean. You can adjust the retention policy by providing `--env BORG_RETENTION_POLICY="--keep-within=7d --keep-weekly=4 --keep-monthly=6"` to the docker run command of the mastercontainer (but before the last line `nextcloud/all-in-one:latest`! If it was started already, you will need to stop the mastercontainer, remove it (no data will be lost) and recreate it using the docker run command that you initially used) and customize the value to your fitting. ⚠️ Please make sure that this value is valid, otherwise backup pruning will bug out!
|
||||
|
||||
#### Are remote borg backups supported?
|
||||
|
||||
Not directly but you have multiple options to achieve this:
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
- [ ] When starting the mastercontainer with `--env NEXTCLOUD_UPLOAD_LIMIT=11G` it should change Nextclouds upload limit to 11G. See https://github.com/nextcloud/all-in-one#how-to-adjust-the-upload-limit-for-nextcloud for allowed values.
|
||||
- [ ] When starting the mastercontainer with `--env NEXTCLOUD_MEMORY_LIMIT=1024M` it should change Nextclouds PHP memory limit to 1024M. See https://github.com/nextcloud/all-in-one#how-to-adjust-the-php-memory-limit-for-nextcloud for allowed values.
|
||||
- [ ] When starting the mastercontainer with `--env NEXTCLOUD_MAX_TIME=4000` it should change Nextclouds upload max time 4000s. See https://github.com/nextcloud/all-in-one#how-to-adjust-the-max-execution-time-for-nextcloud for allowed values.
|
||||
- [ ] When starting the mastercontainer with `--env BORG_RETENTION_POLICY="--keep-within=1d --keep-weekly=1 --keep-monthly=1"` it should change borgs retention policy to the defined one. This can be checked when creating a backup and looking at the logs.
|
||||
- [ ] When starting the mastercontainer with `--env WATCHTOWER_DOCKER_SOCKET_PATH="$XDG_RUNTIME_DIR/docker.sock"` it should map `$XDG_RUNTIME_DIR/docker.sock` to `/var/run/docker.sock` inside the watchtower container which allow to update the mastercontainer on docker rootless.
|
||||
- [ ] When starting the mastercontainer with `--env AIO_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.
|
||||
- [ ] When starting the mastercontainer with `--env NEXTCLOUD_TRUSTED_CACERTS_DIR=/path/to/my/cacerts`, the resulting nextcloud container should trust all the Certification Authorities, whose certificates are included in the directory `/path/to/my/cacerts` on the host.
|
||||
|
|
Loading…
Reference in a new issue