Backing/Restoring up openHAB2.x

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.


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]

Doh. I didn’t realise there was recently a new post here I made this because I was asked to.

1 Like

While there is some overlap, the focus on the two are different. @dim’s post is more focused on setting and managing the settings while this is more focused on backup and restore.

I think there is a need for both. Thanks for the work!

Awesome share @Benjy!

This will help a lot of OH2 users :sunglasses:

Very useful summary but I believe it may be around the wrong way.
should be

Configuration Folder
Linux (Packaged): /var/lib/openhab2/


Userdata Folder
Linux (Packaged): /etc/openhab2/

Could also add
Runtime Folder
for the case where the user may wish to revert to an earlier version after an update.

Hmm … interesting.
Found 4 files
scp: /var/lib/openhab2/.java/fonts/1.8.0_111/ Permission denied
scp: /var/lib/openhab2/tmp/+~JF7228911213193846329.tmp: Permission denied
scp: /var/lib/openhab2/tmp/+~JF1469258209804490975.tmp: Permission denied
scp: /var/lib/openhab2/tmp/+~JF5554311557797463520.tmp: Permission denied
that could not be scp’d to my desktop backup folder from the Raspberry Pi. Had to first cp these to the Raspi home folder, chown them to pi:pi and then could scp them.
Makes for a bumpy backup process and an even more bumpy restore.
Not sure if the .tmp files are necessary for a complete backup. If they are then the filenames are likely different sometimes when backups are done. The .properties file would be a mandatory part of the backup.

No, the configuration folder by definition is /etc/openhab this is where all of your text configuration files go.

/var/lib/openhab is the user data folder which contains all of the stuff saved by the oh runtime.

1 Like

Ok. I accept that I had a different understanding of the definitions. Thanks for clarifying.

Hi, but OPenhab 2.2.0 is not yet released, is it?
So the backup scripts that are already described in the documentation are not yet available, right?

You can install and use 2.2 by downloading or using the installation for the snapshot version for your specific platform.

There is work ongoing to better manage versioning of the docs but for now the published docs are for the absolute latest snapshot version so you will see things that only apply to the latest version.