-
-
Notifications
You must be signed in to change notification settings - Fork 391
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
Backup and restore scripts for Linux/MacOS #507
Conversation
That's my best stab at it for now, would appreciate reviews, suggestions and testing @ThomDietrich and @whopperg :) |
Like it! I previously also added something like a backup mechanism for QNAP NASs. As soon as this is ready I'll adopt it. |
Thanks @thopiekar, looking at the folder structure it for QNAP NASs it should work fine, have you already tested it for it? @kaikreuzer, could you test these scripts on MacOS? |
Hey @BClark09, I went through the code thoroughly and everything looks great. The only thing I still don't quite like is "Usage: ./runtime/bin/backup [filename]". Feels unnatural to demand a relative path for execution of a script/program. As a user I'd like to run the script with an absolute path or right from inside the Furthermore I'm wondering if we should add symlinks to these scripts to |
@BClark09 No, I haven't but implemented a simple function to my service script to make backups of the whole distribution (only working when openHAB is offline, of course.). |
This is only necessary if the OPENHAB_* environment paths are unknown. It'll work anywhere otherwise. I'd rather not try to work out where the appropriate path is from the file location, since this starts to break down with symlinks and I can't think of a platform independent way of doing it.
Actually, I was considering adding /usr/bin/openhab soon to add the commands:
thoughts? Perhaps for another issue. |
I agree with @ThomDietrich. It would be nice, if the filename would be optional. This way people can decide whether they want to create a archive inside the distro or eg. outside. |
Tested, not working. I get the message (both on backup and restore)
and the backup only contains empty conf and userdata folders. Regarding the message on restore:
Why not? If I restore a backup, I would want the setup of that moment and not some mix of current stuff and restored stuff. Or do I misinterpret the notice? |
@kaikreuzer That's why I make a full copy of the whole distro and then if something goes wrong I remove everything and restore all from the backup. |
Alright will rework. Not sure about that -R, -r error though. It only uses one. |
Checking the man page it says:
so by specifying |
... and indeed, when I remove the |
Alright, made a couple of changes that should mean that the script can be called from anywhere, and now should work on MacOS (Thanks @kaikreuzer!)
You didn't misinterpret, but I understand this is probably the desired choice. How best to proceed with that then? Delete all but the specific |
Hi all, I've made some adjustments so that it completely replaces userdata and conf, getting rid of anything that wasn't in the backup. Please could you check and test these new changes, as we need to eliminate anything that could be potentially dangerous. @kaikreuzer, will these new changes work on a mac? |
I'm writing the Windows version of this and I'm noticing that you put the backup in runtime\bin\backups. If you would then use upgrade that backup would then be deleted. Is this intended? Is there a plan to modify upgrade to handle retaining the backup? |
Hi @bdleedy, the backup should be stored in openhab_home/backups by default. Is that not the case here? The line:
should point two directories up from where the backup script is. |
NM. Duh. Apparently too much code floating around in my head yesterday. Thanks. |
2acb05c
to
89bd9c0
Compare
Alright, I think I've finished with this. @ThomDietrich, @kaikreuzer and @thopiekar, I've taken all comments on board. Please let me know how you get on with testing and reviewing the two scripts. I've tested on a debian virtual machine, but please try to break the scripts as much as possible. |
|
||
## Restore configuration | ||
echo "Restoring openHAB with backup configuration..." | ||
command cp -af "$TempDir/conf/"* "${OPENHAB_CONF:?}/" || { |
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.
what's the command
needed for?
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.
Some distributions use an alias for cp which includes the -i flag. There are a ton of files here, so that might not be the best of things to include.
https://serverfault.com/questions/119869/turning-off-cp-copy-commands-interactive-mode-cp-overwrite
https://superuser.com/questions/643388/force-copy-when-i-is-used-in-bash-alias
@BClark09 I have tested it on Mac, seems to run smoothly! 👍 |
Any further comments/tests by the others? Or do you think we are good to merge? |
I did not get around doing any tests (my time is a bit limited atm) but I went through the whole code and it LGTM. |
This pull request has been mentioned on openHAB Community. There might be relevant details there: |
Signed-off-by: Ben Clark <ben@benjyc.uk>
89bd9c0
to
35d6663
Compare
Hi @ThomDietrich and @kaikreuzer, would you be able to test this once more? I cleaned up and used the scripts on my own home today so these should be fine to use. I've tried to harden the script as much as possible but please try to break it if you can :) |
LGTM. Great work @BClark09 ! |
TOP!!! @BClark09 |
Thanks @BClark09, successfully tested it on Mac as well! |
Awesome, thanks everyone! Shall I put a post up on the community forums about this? |
Related to #499
Signed-off-by: Ben Clark ben@benjyc.uk