Skip to content

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.

@vercel
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
@dotboris
Copy link
Contributor Author

👋 I've stopped using autorestic and I therefore don't really have a need for this PR anymore. As such, I won't be maintaining this PR or keeping it open. If someone wants to take over my work and get this over the finish line feel free to do so.

@dotboris dotboris closed this Nov 23, 2025
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