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
Multiple profile configuration #45
Conversation
Resolved conflicts: etc/restic/b2_env.sh.template etc/restic/b2_pw.txt etc/restic/b2_pw.txt.template etc/restic/pw.txt etc/systemd/system/restic-backup@.service usr/local/sbin/restic_backup.sh
Improve organization of configurations by extracting them to different environment files that enable different "backup profiles". Profiles are loaded by passing them as systemd parameter.
Hi @erikw, if we move ahead with this PR I would suggest to go with "squash-merge" as the log became a bit convoluted. Doing this the PR will be still co-authored I think :) Cheers! |
# Conflicts: # Makefile
# Conflicts: # README.md
88c5b08
to
53e246c
Compare
This was wrong in master branch already.
for homedir in /home/*; do | ||
if [ -f "$homedir/.backup_exclude" ]; then | ||
exclusion_args+=" --exclude-file $homedir/.backup_exclude" | ||
for backup_path in ${BACKUP_PATHS[@]}; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question here: What will happen if BACKUP_PATHS=/home/
and, then there is a /home/someuser/.backup_exclude
file? The file makes reference to a specific user, while the paths refer to the higher level directory /home
.
The previous behaviour takes the someuser
exclusion file in consideration, but after the change what will happen? I think it will be omitted, right? If that's right, may be confusing. What do you think? :D
Maybe aside of backup_paths/.backup_exclude
, also all user homedir .backup_exclude
can be considered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this was the original intention, got-cha! Thanks
I had forgotten. We should look for .backup_exclude
for each mount-point, and additionally each user dir in /home
, if /home
is in the backup path.
Will fix!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, please check 424bb0c
I tried it out locally, seemed to work... 😅
Thanks @gerardbosch for picking this up and running with it. I'm (also) having trouble navigating all of the changes since 2019, so I'll start from scratch and install this proposed merge on a new system and see if I find anything confusing or broken. Good stuff! Thanks! |
@mfeif Hallo! I'm happy to hear that you want to try this out. Perfect! Could you maybe wait just 1 day or so, as there are still some changes coming in to this PR :) But soon after that, having someone trying out the updated setup from scratch would be terrific!! |
Of course! |
Great job @gerardbosch picking this up from @mfeif from the good start in #14. We're soon getting there! Review status from me
@gerardbosch @mfeif as I reviewed the changes I asked myself if it would make sense to make the |
That seems an obvious thing that someone will eventually need/want. Good thinking. Putting those in .env files might be messy, so separate text files might be nice. Can we still cascade well, in the event that there is NOT a per-target customization? Without the natural over-ride mechanism with ENV variables? Or can those two configuration items just be IN ENV variables? On my (old) system, excludes are in there, but I have just one password. |
I think it should work with the same approach for overriding
|
No, it was the master branch on this repo, which doesn't include all the relevant changes. My notes will come in my next post in a little bit... |
Hey friends, I'm finally getting to testing this. Here are the questions/concerns I have found while doing that. First, I tried following the makefile instructions:
The script file itself seems to work great! My test backup is showing up in B2... That's a lot there; I'll clean this stuff off the server and go through the manual config notes next, but in case we want to talk about any of the above first, I'll stop here for the night. |
Really great feedback @mfeif! I add my replies inline below
The addition of the unmeetered check comes from #17. I would agree that this is an optional feature and should not be installed by default. There could possibly be a separate make target like
Same here, #58. I would like to include the scripts in the repo as example or starts of custom solution, but it need not be installed by default. You are right.
No worries about this. The Makefile does what is intended, but it does not matter because I will completely re-write the Makefile to solve #49 after this PR is merged. I have not decided exactly yet for now, but I think I will try to create a local
Yes you are correct. This whole thinkg about copy and rm during install comes from #15 (check for background). However this will also be made in a different way when I fix #49. So no need to worry about this for now :)
Hmm could you maybe elaborate on what you mean by definitions? I'm not sure I follow :). Here's a comparison between
To me, it looks like they both provide the same features and capabilities.
Hmm that the targets use the same script ( I added a note in README about editing this value. To solve the problem with multiple backup profiles firing off at the same time, we can sleep a random delay on each execution. This is a common way to solve the problem in cronjobs. We can update - ExecStart=bash -c 'source /etc/restic/%I.env && /usr/local/sbin/restic_backup.sh | systemd-cat'
+ ExecStart=bash -c 'sleep ${RANDOM:0:3600} && source /etc/restic/%I.env && /usr/local/sbin/restic_backup.sh | systemd-cat' This would make it sleep some random time between 0 to 60 minutes. @mfeif @gerardbosch sounds good? :)
This is the most important thing after all ✅ :D |
Do you think the value could be reduced to 5 minutes or something like that? I'd expect my backup runs soon after my laptop starts instead of one hour later. Could |
Sure! A user of multiple profiles can easily adjust the value anyways to optimize for their system. The best solution would of course be something like a lock file (if load or bandwidth is a problem), but the complexity of this outweighs the benefits. For now, a 5 minute random sleep should suffice! I'll push this in a moment. Apart from that, I think the only remaining question was
Then we can soon finally merge this! |
Great stuff, guys. I will do the manual instructions following today. Thanks for addressing all of my questions point by point!
I agree that's the only thing; sorry I wasn't more clear. The comparision there is actually _global.env, not default.env, but really I just need to explain myself better: in my old version linked here; inspect the example.env file... we had local specific excludes:
If I'm reading the current set of files, one can only put excludes into _global.env... it seems like it would be common that different backup plans/targets might have their own exclude setups, and putting them all in _global kinda removes the point of even having the cascading/inheriting behavior. I'd recommend we put those back, and make sure that the script uses BOTH excludes from _global and specific .env files |
Hi @mfeif if I'm understanding you fine, that's something already possible. Check if this comment helps: #45 (comment) The thing is that you can override any variable defined in EDIT: Oh! I think I get what you mean! You want to be able to define multiple exclusion files, is it? I've seen somewhere in the repo something like |
@gerardbosch exactly, I will add extra args feature here #56 |
Yeah, that's what I mean. Looking at restic docs about excludes there are a number of ways to add excludes; if we want to keep that as files (rather than explicit mentions) we can pass more than one exclude file:
I might suggest that the script just look in both places (specific and global) for I would also suggest that we change that variable to Thanks! |
@mfeif Good idea. Done ✅ After #56, one can for example do in # Complete override of global exclude file set in _global.env
RESTIC_BACKUP_EXCLUDES_FILE=/different/exclude/file
# and/or add extra exclude files
RESTIC_BACKUP_EXTRA_ARGS="--exclude-file /exclude/file/a --exclude-file /exclude/file/b" |
I'm not sure we need to use the --extra-args feature for my idea, since restic can take multiple Would it be hard to modify the script to look for another env variable |
These comments are about the second set of instructions in the readme; the detailed ones:
I think everything else looks great! Nice and thorough. Good stuff! |
I see what you mean. It could certainly be done :). The aim of the project is to keep it simple and extensible, so have and EXTRA_ARGS would be more general and cover more cases, so let's go with this for now. I'll get started with #56 asap!
✅ good point, fixed!
✅ good catch again. Fixed!
|
aaaaand merged! Thanks a lot @mfeif & @gerardbosch for your collaboration :) I will update CHANGELOG, make a new release and also update the arch PKGBUILD in a bit @gerardbosch the squash-merge preserved co-authors like you said :) |
Nice :) You're welcome! |
Thanks friends! Good stuff! |
Improve organisation of configurations by extracting them to different environment files that enable different "backup profiles". Profiles specify a set of configurations and are loaded by passing them as a systemd parameter.
Resolves #12