runrestic icon indicating copy to clipboard operation
runrestic copied to clipboard

Cache handling

Open darkdragon-001 opened this issue 4 years ago • 5 comments

Optimized cache management is important to keep cloud storage costs under control.

I would like to use --cache-dir for all operations. Having this built-in makes sure I don't forget it for any command.

The other options like --with-cache/--no-cache can be specified via -- --option if you don't want to add official support.


Furthermore, behavior different from restic default should be documented: https://github.com/sinnwerkstatt/runrestic/blob/762273951f8fd7b918b917293d0fa94fc0b34969/runrestic/restic/tools.py#L89-L92

darkdragon-001 avatar May 25 '20 08:05 darkdragon-001

I thank you for all your comments. You clearly know what you're talking about.

Would you mind create a PR or two for some of the suggestions you're making?

Cheers

andreasnuesslein avatar May 27 '20 18:05 andreasnuesslein

How should it go in the config file?

darkdragon-001 avatar May 28 '20 00:05 darkdragon-001

So according to restic, it should work to just set XDG_CACHE_DIR because all restic commands seem to honor that. However I know I put in logic that is thwarting that at the moment. So I suggest we throw out the custom if os.geteuid() == 0: logic. Next we recommend setting XDG_CACHE_DIR in [environment] in the docs and lastly print a warning on running runrestic when no explicit XDG_CACHE_DIR is set to let the user know what runrestic assumes then. i.e.: [warning] You have not explicitily set XDG_CACHE_DIR. Falling back to /var/cache/

andreasnuesslein avatar May 28 '20 07:05 andreasnuesslein

I just noticed RESTIC_CACHE_DIR environment variable is also supported. So this can just be used in the config environment section if the user wants to use it! Therefore, I would just remove this code block...

I suggest to add a warning right now that the behavior will change in a future version when one of the quoted code blocks is executed. And then just remove this code in the next bigger update.

I added an issue to get a complete list of environment variables in restic/restic#2763.

darkdragon-001 avatar May 29 '20 12:05 darkdragon-001

You can pass env to subprocess.Popen().

I suggest the following:

env = { name: os.environ[name] for name in ['HOME','XDG_CACHE_DIR','TMPDIR'] if name in os.environ }
env = { **env, **config['environment'] }

darkdragon-001 avatar May 29 '20 21:05 darkdragon-001