Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prune support using a separate service and cron schedule #36

Merged
merged 1 commit into from
Jun 3, 2020

Conversation

djmaze
Copy link
Owner

@djmaze djmaze commented Jun 1, 2020

closes #22

@djmaze djmaze added this to the 1.2.0 milestone Jun 1, 2020
Copy link

@zoispag zoispag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! :)

Question: Is there a fundamental issue with starting a second go-cron process for pruning? I was thinking, if PRUNE_CRON is provided, then a separate process would run inside the same container, to handle the pruning, in a different schedule, whereas the main PID will always be responsible for performing the backups.

@djmaze
Copy link
Owner Author

djmaze commented Jun 1, 2020

@zoispag There are several points to this:

  1. Of course it is possible to spawn a second go-cron instance in the background for the prune job. This prevents proper process management and container termination handling by Docker, as the second instance is not waited for by its parent process. This is a minor issue though which probably does not lead to problems in practice. Also, the output of both jobs is now tangled up.
  2. The prune process needs a huge amount of memory, so it makes sense to run it on a different node with enough resources. You can also set different resource limits for this container (either using compose v3 limits in swarm mode or compose v2 limits for non-swarm mode with docker compose).
  3. When using Docker swarm mode (as I am doing), the backup container has to be run all nodes while the prune process only needs to be run on one. That node, as said above, should have enough resources for the prune process. It can be selected effectively by setting (memory) resource reservations on the service.

If you don't have big issues with that approach, I prefer to keep this as two separate containers / services.

EDIT: If you don't like the duplication of the env variables, you can use the env_file setting in the compose file.

@zoispag
Copy link

zoispag commented Jun 1, 2020

I am not using swarm, but I can see the reasoning behind. I am also aware that restic prune utilizes way too many resources. In my setup, I am using docker-compose, and for some of the combination of services (for example x.test and x.prod), I am using the same s3 bucket as a repo. Thus, I have to add a new container in docker-compose.override.yml for one of these combinations. The other approach would allow me to specify only the PRUNE_CRON as an ENV variable in docker-compose.override.yml. But I agree, not much of a hassle, since I still have to do something either way.

If you don't like the duplication of the env variables, you can use the env_file setting in the compose file.

Of course, there are no ENV variables in the compose file. The docker-compose.yml itself, is shared across more than 80 servers, which are happily backed up using resticker 😄

@djmaze djmaze merged commit 630d1d2 into master Jun 3, 2020
@djmaze djmaze deleted the add-prune branch June 3, 2020 21:37
jeankhawand pushed a commit to jeankhawand/resticker that referenced this pull request Aug 30, 2024
Add prune support using a separate service and cron schedule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow prune to be on a different schedule
2 participants