Recover Configuration through REST API

Hi openHAB friends,
I started to play with openHAB and coming close to a productive system slowly.
Unfortunately the SD card in my Raspi is corrupt now AND my backup system obviously in parts too :frowning:
No chance to connect to console, but still working out of the RAM.

I realised to get item and sitemap as xml file through the REST API. My questions:
a) Any chance to get rules and functions as well?
b) any chance to import the xml files afterwards in a new system or to convert it to a normal syntax for openhab? Or just write it new with xml content as note sticker?

Would be great to get a hint for a good way to recover. Maybe on raspian way or so… :-/

Thanks in advance,
Starbucks

PS: Great community! I got all my questions or irritations closed just by reading the wiki or in this coomunity! Excellent :slight_smile:

I’m afraid there is no mechanism to get rules, scripts, persistence, or your main config through the REST API. The REST API only lets you send commands or get information about Items.

Furthermore, there is no mechanism to import the XML returned by the REST API because I believe that the Binding part is not included. So even if there were a way to convert the XML listing of Items back to an Items file, the binding part would be missing.

Similarly with the sitemap, I know of no mechanism to convert the sitemap XML returned by the REST API to a .sitemap file.

If OH is still running perhaps ssh is working too? I’ve not experienced one of these SD card corruptions so I don’t know how completely it destroys the data on it. But if there is a way to get on the machine via ssh or the like and if you can somehow managed to read at least parts of the file system you can copy from there. Otherwise I’m afraid you are stuck and will have to recreate everything.

When you rebuild your server, I recommend searching this forum for “read only pi” and I’m sure you will find one or more postings where people have described how they set up their Pi so the SD card is read only to avoid these corruption issues.

Similarly, there are a number of approaches people use for backups. Personally I have a git server and I check my changes into it which gives me a backup (and change tracking) of my configs.

Thank you very much for your reply Rich!
At the end you underlined my assumption that there isn’t any way over the REST API.
Unfortunately there isn’t any connect over ssh or similar possible. The card is out of the Raspi and isn’t readable in differend laptops, cardreaders & OS. Looks like a defect on the lowest level, the physics :frowning:

Result therefore is to start again and test myself, what I have learned already :smiley:

I learned for sure, that I’m as the guy who is calling & crying for backups always, never tested my own OH playground backup with crontab & copy. It worked a short time until mid of march, but since then not :frowning: That’s nearly my starting point :-/ Ok, murphys law…

Thanks for your hint with the git server. For my start to rebuild everything I will start a git server as well. -> learning through pain actually :frowning:

See this posting for more details about how I do it and some ideas from others.

Once more a big thank you, Rich! You kicked me imho in the right direction.

I played around with git, SVN, Docker and several backup concepts on top of a hardening scenario (24x7 for RPI “read only”).

At the end in short words, I have now a RPI with separate /boot partition on the SD card. The rest as a partition in a LUN on the new Synology NAS. Additionally the ~OH/configurations folder will be backuped / saved on the NAS at every change in it. With a script for inotify & rsync and a rotate mechanism. The last point isn’t already now, but it will be in live today :slight_smile: That’s my easy way for version saving, instead git and the needed push, announcement and accepting and merge and so on. Maybe I understood it to less, but in my playing rounds it was to complex in the needed steps for me… I’m going old :older_man:

After this painful experience I just motivate everybody, think on backup before you running in this situation!!!