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

Allow lockfile path to be configured #384

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dotboris
Copy link
Contributor

@dotboris dotboris commented Jul 3, 2024

The goal of this feature is to allow users to control the path of the lockfile. This is useful in situations where you don't want the lockfile to default next to the config file.

For my use case, I want to generate the config file with Nix which will store it in a read-only path. In such a situation autorestic won't be able to create the lockfile. This flag will let me specify a different writable path for the lockfile.

Copy link

vercel bot commented Jul 3, 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 7:00pm

@PHLAK
Copy link

PHLAK commented Oct 16, 2024

I just started using autorestic and was looking for a way to control this. My reasoning is that I'm putting the config file in /etc/autorestic and running it on a schedule with a systemd timer but having the lock file in /etc doesn't make sense. I want to put it in /run/lock or somewhere similar.

@PHLAK
Copy link

PHLAK commented Oct 16, 2024

Also, it would be nice if we could set the lockfile path in the config file similar to the cache-dir.

version: 2

global:
  all:
    cache-dir: /var/cache/restic
    lockfile-dir: /run/lock/restic/

...

@dotboris
Copy link
Contributor Author

I like the idea of specifying the lockfile through the config file. It makes a ton of sense to me.

I don't think that we can fit this under the global section tho. That section is meant to host options (as in command line options) that are passed to restic based on the command line. In your example, global.all.cache-dir = /var/cache/restic makes it so that every restic command gets called with --cache-dir /var/cache/restic. Since this lockfile is an autorestic concept it can't really live in there.

What do you think of adding this option at the root of the config. So it'd be something like this:

version: 2
lockfile: /var/lock/restic/autorestic.lock.yaml

global:
  all:
    cache-dir: ...

...

Note that in my example lockfile points to a file and not a directory because there's really only one lockfile for autorestic.

@PHLAK
Copy link

PHLAK commented Oct 17, 2024

I don't think that we can fit this under the global section tho. That section is meant to host options (as in command line options) that are passed to restic based on the command line.

That's true. Making it a top-level configuration option makes sense then.

Note that in my example lockfile points to a file and not a directory because there's really only one lockfile for autorestic.

I was debating this myself in my example so I think this also makes sense.

In a future commit, I'll need the lockfile code to access the config
file. This solves an import cycle.
@dotboris
Copy link
Contributor Author

I've implemented the basic functionality of reading the lockfile path from the config. I still need to do some of the finishing touches: documentation and tests.

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.

2 participants