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 init backend config to automatically initialize restic repository #401

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dotboris
Copy link
Contributor

@dotboris dotboris commented Oct 14, 2024

This PR adds a new init option to the backend config. Setting init: true on a backend makes it so that autorestic will automatically initialize the restic repository that powers that backend.

This initialization is done in a lazy fashion. If the repository is already initialized nothing will happen.

The initialization process will happen when a backup is triggered through:

  • autorestic backup ...
  • autorestic cron (the initialization happens only when the backup happens, not during each invocation of the cron handler)

Note that I've updated autorestic check to keep its auto-init behavior but to rely on the new implementation for this PR.

Checking if a repo exists is done by calling restic cat config as documented in https://restic.readthedocs.io/en/latest/075_scripting.html#check-if-a-repository-is-already-initialized. I chose this method over the existing method of calling restic check because this method performs fewer IO operations on the repository. This matters in cases where the repo is stored on a cloud platform where these IO operations turn into API calls which end up costing money for the user.

Copy link

vercel bot commented Oct 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
autorestic ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 10, 2024 6:20pm

When this option is set to `true`, the backend will automatically get
initialized during the backup process. This applies to invoking
`autorestic backup` or when `autorestic cron` actualy performs a backup.
@dotboris dotboris marked this pull request as ready for review October 14, 2024 18:34
@dotboris dotboris changed the title Init backend on the fly before backups Add init backend config to automatically initialize restic repository Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant