Note: The information in this post is old, as of version 2.2.0 (and it’s snapshots) openHAB is now distributed with backup and restore scripts! See here for more details.
openHAB 2.x currently has two different ways of setting up things: Either through textual configuration or through the user interface which saves to a “jsonDB” database. If you’re looking to backup openHAB then you should look to backing up both the textual configuration files and the database folders.
Locations
I will be talking about various locations, use this section to translate between your version of openHAB2 and the path.
UserData Folder
Linux (Packaged): /var/lib/openhab2/
Others (Manual): /[extracted location]/userdata/
Configuration Folder
Linux (Packaged): /etc/openhab2/
Others (Manual): /[extracted location]/conf/
#Making sure bindings will reinstall with a new version:
Make sure you have a list of all the extensions you have installed so that openHAB can reinstall them when first launched, this should be found in the /services/addons.cfg
folder inside your configuration folder and should look something like this depending on what you need:
# A comma-separated list of bindings to install (e.g. "sonos,knx,zwave")
binding = zwave,ntp,weather,hue,network,astro,systeminfo
# A comma-separated list of UIs to install (e.g. "basic,paper")
ui = basic,paper,habmin
# A comma-separated list of persistence services to install (e.g. "rrd4j,jpa")
persistence = mysql,mapdb
# A comma-separated list of actions to install (e.g. "mail,pushover")
action =
# A comma-separated list of transformation services to install (e.g. "map,jsonpath")
transformation = map
Backing up openHAB
As mentioned earlier, it is important to backup both textual and database configuration, even if you rely on just one. This is because there are some settings for the user interfaces that can be found in the configuration folder as well as important settings for bindings (e.g. zwave node .xml files) in the UserData folder.
Simply make a backup by copying both configuration folder and UserData folder, into a safe place. If you want to be selective about what you’re backing up the configuration folder should be self explanatory, for UserData though:
[..]/etc/ contains settings related to jetty, including the java keystore.
[..]/jsondb/ contains things, items and other properties not defined in your own texts.
[..]/persistence/ contains databases for internal/java persistence services.
[..]/webapps/ contains html files for UIs.
[..]/zwave/ example folder for a binding, in this case: z-wave.
Restoring openHAB
To restore openHAB, make sure openHAB is not running then simply move these backup folders to the respective locations above When you restart openHAB, give it some time to reconfigure itself and you should be all set!
Make sure that openHAB still has the permission to modify the file contents in these folders, This is more relevant in Linux and can be done with the following command (replace the contents of the square brackets with the appropriate path):
sudo chown -R openhab:openhab [userdata folder]
sudo chown -R openhab:openhab [configuration folder]