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

Add backup/restore scripts #499

Closed
BClark09 opened this issue Jul 28, 2017 · 18 comments
Closed

Add backup/restore scripts #499

BClark09 opened this issue Jul 28, 2017 · 18 comments

Comments

@BClark09
Copy link
Member

BClark09 commented Jul 28, 2017

Continuing on from #299...

Separate files that backup and restore the openHAB configuration should be made. Users should be able to specify a file for the archive to be created/extracted depending on the script.


General

  • Assume that the scripts are being called from openHAB's root directory or work backwards from the script path (../../).
  • If no filepath is specified, save to [openHAB]/backups.
  • If no filename is specified, use a timestamp.
  • Backups should not contain userdata/cache , userdata/tmp and any of the following files:
    • /userdata/etc/all.policy
    • userdata/etc/branding.properties
    • userdata/etc/branding-ssh.properties
    • userdata/etc/config.properties
    • userdata/etc/custom.properties
    • userdata/etc/version.properties
    • userdata/etc/distribution.info
    • userdata/etc/jre.properties
    • userdata/etc/profile.cfg
    • userdata/etc/startup.properties
    • userdata/etc/org.apache.karaf*
    • userdata/etc/org.ops4j.pax.url.mvn.cfg

Specific to Linux/Mac OS

  • Use $OPENHAB_CONF and $OPENHAB_USERDATA first if they exist.
  • Files should be backup and restore with no extension and executable rights set (755).

@whopperg, you have already done most of this, care to finish it off and send a PR?


Specific to Windows

  • Use %OPENHAB_CONF% and %OPENHAB_USERDATA% first if they exist.
  • Files should be backup.bat and restore.bat, there should be no need to use powershell here.

@bdleedy and @ghys, I'm not sure if anything exists here yet, care to take a look?

@ghys
Copy link
Member

ghys commented Aug 1, 2017

I'm not aware of anything existing for backup and restore on Windows.
I have the same opinion about PowerShell vs batch files as in #500.

@BClark09
Copy link
Member Author

BClark09 commented Aug 3, 2017

Another thought, backups should be platform independent. It should be perfectly reasonable for a user to move their windows installation to a Linux server, or visa versa. For this reason, we should use zip.

Some methods of compressing with zip will remove previous file ownership. I'd suggest using a file inside the backup to determine a couple of things so that they can be restored later:

backup.properties

version=2.1.0
timestamp=17-08-03_11-34-55
user=openhab
group=openhab

Secondly, if no path is specified where should the zip file be stored? For manual installations this can be openhab2/backups but for apt/rpm? @ThomDietrich, do you have any ideas?

@BClark09
Copy link
Member Author

BClark09 commented Aug 3, 2017

@whopperg, I'm happy to do it for linux/mac if you've not got the time and if it's okay with you. I'll start on the weekend.

@ThomDietrich
Copy link
Member

Hey! Good idea. I will not be of much help with the project but will try to annoy all of you with comments as good as I can ;)

Regarding the backup location: Hmmm I'd say /var/backups/openhab2 would be the most linux-way-of-things location. I agree that it is not the most convenient location for our fellow Linux newbies. The users home is the other extreme and would be easy to find, even WinSCP will start browsing there. I'd not vote for it. A location below /var/lib/openhab2 is also not a good idea as the whole directory itself is included in the backup.
I might add that the location of the backups, wherever they might end up is easily mounted to /srv/openhab2-backup under openHABian just like the rest of the interesting openHAB folders. Hence I'd say we don't need to worry about our Linux newbies too much...

So yeah. Wdyt about /var/backups/openhab2?

@BClark09
Copy link
Member Author

BClark09 commented Aug 3, 2017

/var/backups is specific to debian I think.

I'd prefer "/home/backups" but I think it shouldn't matter too much if we make it clear where to define the default path (/etc/default/openhab2).

Another option is using "/var/lib/openhab2/backup", but not including that folder in the actual backup. i.e:

if [ "$OPENHAB_BACKUP" -eq "$OPENHAB_USERDATA/backup"]; then
[...]
fi

@ThomDietrich
Copy link
Member

that might be but what gives. We can simply create the backups folder on other OSs. The answer you linked to suggests "you could put them in /backups, or even /home/backups" which both are very bad choices in my eye. Noone should start to mess up the root folder and home should stay restricted to user accounts. Before we mess around in these areas ask yourself this: who will be mad at us for creating /var/backups?

@ThomDietrich
Copy link
Member

Okay I've read up on the meaning of "/var/backups is reserved". It may not be the best solution after all.
https://askubuntu.com/questions/575679/what-is-the-default-location-for-backup-files-of-another-server

@whopperg
Copy link

whopperg commented Aug 4, 2017

@BClark09: Please do so! Feel free to use what ever you can / need from the script!

@BClark09
Copy link
Member Author

BClark09 commented Aug 4, 2017

Thanks @whopperg, I'll have a go this evening.

@ThomDietrich, FHS 3.0 defiantly points to /var/lib/openhab2/backups being the most appropriate directory to use, and to me having it under where every other "user-initiated" file is makes sense. It shouldn't be too hard to stop backups appearing in the backups. You'd know openHAB's Linux users best though, any other suggestions as which to use?

@ThomDietrich
Copy link
Member

ThomDietrich commented Aug 4, 2017

Yesterday I was answering from the phone. After reading though quite a few recommendations and checking with other applications just now, I'm convinced of /var/lib/openhab2/backups. Let's do that.

@bdleedy
Copy link
Contributor

bdleedy commented Aug 6, 2017

@ghys Agreed, stick with PS. Are OPENHAB_CONF and OPENHAB_USERDATA new environment variables that get set?

@bdleedy
Copy link
Contributor

bdleedy commented Aug 6, 2017

@BClark09 I'm trying to keep in line with what you have envisioned for the non-MS side. Are you thinking one script that contains both functions or a discrete script for backup and restore?

@ghys Graphical folder picker or just all command line?

@ghys
Copy link
Member

ghys commented Aug 6, 2017

@ghys Graphical folder picker or just all command line?

I'm partial to always avoid invoking blocking dialogs and other GUI in command line scripts. Those scripts could be called from another one without user interaction - or from a PS remoting session, Windows Core Edition etc.

@BClark09
Copy link
Member Author

BClark09 commented Aug 6, 2017

Hi @bdleedy, I've separated the scripts. You can see my attempt for a Linux/MacOS implementation here

@bdleedy
Copy link
Contributor

bdleedy commented Dec 13, 2017

Need tester for backup script. Hoping to have restore script done tonight.

@JohnnyXXX
Copy link

@bdleedy I'm a windows user and still on the migration of 1.8.3 to OH2.x but willing to play aroung with your script. Please tell me what/how to test and what kind of feedback do you need? Any specific test cases to run? Any pre-conditions required?

@bdleedy
Copy link
Contributor

bdleedy commented Dec 16, 2017

update.ps1 and backup.ps1 should be in \runtime\bin. Open powershell as admin, cd to the root of your OH install. run ". .\runtime\bin\update.ps1" then "update-openhab"

@kaikreuzer
Copy link
Member

This is available by now.

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

No branches or pull requests

7 participants