Schedule: Capture os.Environ on schedule creation#212
Schedule: Capture os.Environ on schedule creation#212jkellerer merged 3 commits intocreativeprojects:masterfrom
os.Environ on schedule creation#212Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #212 +/- ##
==========================================
+ Coverage 77.20% 77.43% +0.23%
==========================================
Files 92 93 +1
Lines 9949 9984 +35
==========================================
+ Hits 7681 7731 +50
+ Misses 2003 1990 -13
+ Partials 265 263 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
|
@creativeprojects , btw. not all platforms have case insensitive variables. But this PR makes env vars case insensitive in all cases. Should we differentiate it by platform? (I think yes we should) |
I don't think it would clash with #146 so we're good 👍🏻
Yeah probably 😐 I'm not too familiar with powershell but I'm pretty sure that could cause some issues. |
93ae8f9 to
f35395d
Compare
|
Env vars will now preserve the case. Case folding only applies on Windows. Will manually test the changes first. |
Trying to preserve the case of environment variables where possible. Also using schedule config environment in systemd and launchd.
f35395d to
67ac710
Compare
|
Works fine in launchd and systemd. Manual test was performed in user home with: version: "2"
profiles:
default:
initialize: true
repository: 'local:{{.ConfigDir}}/test-repo'
password-file: 'profiles.key'
backup:
run-before:
- 'echo "Var is [$RESTIC_VAR]" > "{{.ConfigDir}}/test.txt"'
source:
- '{{.ConfigDir}}/test.txt'
schedule: "hourly"systemd: $ resticprofile generate --random-key > profiles.key
$ RESTIC_VAR=1 resticprofile schedule
$ resticprofile backup
$ cat test.txt
Var is []
$ systemctl start --user resticprofile-backup@profile-default.service
$ cat test.txt
Var is [1]launchd: |
|
Think it can be merged. @creativeprojects , what do you think? Please check the environment variables part. I think it works correct now, given the limitation that the config doesn't allow to specify the case, but all unix OS are case sensitive for env vars. The implementation was adjusted to this:
|
creativeprojects
left a comment
There was a problem hiding this comment.
Yes it works well, nice one!
I think we're good to go with this one as well 👍🏻
Thank you for the great work 😉
Fixes: #211
The PR adds a new config option
schedule-capture-environmentdefaulting toRESTIC_*which enables OS environment capturing for schedules at creation time.@creativeprojects - what do you think (it is an enhancement to the existing capture of the profile env)?
Does this work with #146 ?