---
title: 'Complete Guide OpenHAB 2 Backup And Restore : WINDOWS 2018'
source: 'https://youtube.com/watch?v=EQmCflT0CIc'
video_id: 'EQmCflT0CIc'
date: 2026-08-01
duration_sec: 785
---

# Complete Guide OpenHAB 2 Backup And Restore : WINDOWS 2018

> Source: [Complete Guide OpenHAB 2 Backup And Restore : WINDOWS 2018](https://youtube.com/watch?v=EQmCflT0CIc)

## Summary

This video demonstrates a complete backup and restore strategy for an OpenHAB 2 server running on a Raspberry Pi, with a Windows PC used for preparation and recovery. It covers automating daily configuration backups to a USB flash drive, creating full SD card images for disaster recovery, and restoring the system after a failure.

### Key Points

- **The nightmare scenario** [00:16] — Losing all your openHAB configuration is a serious risk — the video opens by imagining an empty app and unreachable SSH, motivating the need for a simple backup routine.
- **Backup strategy overview** [00:45] — The approach combines a daily automatic backup of the openHAB configuration to an external flash drive with a manual full SD card image backup, covering both frequent changes and rare system-level modifications.
- **Required hardware** [01:15] — You need a Raspberry Pi running openHAB, a Windows computer, an SD card reader, and a USB flash drive the same size as the Pi's SD card (the video uses 32GB).
- **Format the flash drive** [02:49] — Right-click the flash drive in Windows, choose Format, set the volume label to OHBACKUP, and select the exFAT filesystem. This erases everything on the drive.
- **Download the backup script** [03:16] — Grab the OHBackup_script from the written guide on the website and copy it to the flash drive. This script backs up openHAB daily at 12am and deletes backups older than 30 days.
- **Mount the flash drive on the Pi** [04:14] — Install exFAT support with sudo apt-get install, become super user (sudo su), create /mnt/OHBackupDrive, and find the drive UUID with lsblk.
- **Configure fstab for auto-mounting** [05:27] — Edit /etc/fstab with nano and add: UUID=<uuid> /mnt/OHBackupDrive auto defaults,auto,umask=000,users,rw. Then run mount -a and verify with df -k /mnt/OHBackupDrive.
- **Install and test the backup script** [06:08] — Copy OHBackup_script to /bin, make it executable with chmod u+x, and run it. The output should say 'Openhab backup script' and 'Success!'.
- **Schedule automatic daily backups** [07:07] — Run sudo crontab -e, choose nano (type 2), and append '0 0 * * * /bin/OHBackup_script' to execute the backup every day at midnight.
- **Backup non-openHAB Pi data manually** [07:34] — The script only covers openHAB files, so other settings like MQTT server configuration need a manual backup. The video recommends doing this before/after any major change or openHAB update.
- **Create a full SD card image** [08:33] — Shut down the Pi (sudo halt), remove the SD card, plug it into the PC, and use Win32DiskImager to save a complete .img file of the SD card to the desktop.
- **Restore the SD card** [09:14] — After a failure, write the saved .img to a new SD card with Win32DiskImager, boot the Pi, then restore the openHAB config from the flash drive using sudo $OPENHAB_RUNTIME/bin/restore.

### Conclusion

A layered backup approach — automatic daily config backups plus periodic SD card images — ensures your openHAB server can be fully recovered even after a catastrophic failure. The video proves the process by simulating hardware damage and restoring the system to its previous state.

## Transcript

Hey guys Matt here from MKSmartHouse.com and in this video I am going to show you the complete way to backup your openhab server using windows. [Intro]
Imagine that one day you open up your openHAB app on your phone and there is nothing there, you then quickly go to your computer and try to ssh into the server but it just keeps saying At this point all is lost, all your hard work, all the time you put in, simply gone.
But, lucky for you that was just an imagination and it can all be simply avoided by following In this complete guide I will cover exactly how to backup your openhab server.
The way this backup will work is there will be an external flash drive plugged into the raspberry pi and every day the raspberry pi will backup the openhab configuration and Now, this does solve a majority of the backup problem but what about the rest of the pi
Well, since we don't change much non openhab items on the raspberry pi after it is initially set up, we will do a manually backup of the SD card onto the flash drive through the computer.
The items needed to complete this guide are the following: Number one, is a fully setup any model of raspberry pi running openhab, I am using a raspberry pi 3 in a clear enclosure
that has a fan which generates a lot of air flow to the raspberry pi, I also installed I did this much cooling because I never want to run the risk of the pi overheating and
If you want a kit to protect your pi you can find it at mksmarthouse.com/shop. If your pi is not setup check out my home automation server setup guide.
Number two is a computer running windows, if you have a mac computer then check out Number three, is an SD card reader of some kind that can read the type of SD card you
have in your pi, I only need a micro SD card reader but this one reads both sizes of sd Lastly, number four you need a flash drive that is the same size as the sd card in your
pi my sd card is 32gb so I bought a 32gb flash drive. The links to all the parts and guides mentioned are in the video description. Speaking of links in the description, follow @mksmarthouse on twitter, instagram and snapchat
because those are the place where I give sneak peaks on when videos are releasing and also where I ask for your input on topics and future videos. The first thing we have to do is plug the flash drive into the computer.
Next open up file explorer and click on this PC. The next part we are about to do will erase everything on the flash drive so make sure Right click on your flash drive and press format
In the volume label box type in OHBACKUP and in the filesystem select exFAT. Next we need to head over to the written version of this guide on my website, link is in the
Here we need to download the OHBackup_script. This is the script that we setup to automatically backup openhab every day at 12am and it will also delete backups that over 30 days old in order to not fill up the flash drive completely.
So go over to your downloads folder, double click on the zip file and then drag the script Once that is copied over eject the flash drive from your computer.
Grab the flash drive from your computer and plug it into the raspberry pi. Before we get any further I just wanted to show you the basic ui of this server to demonstrate that this pi is fully configured and has a sitemap with items in it in other words it
I have already done this process to my main openhab server which is why I will be using I recommend having the written version of this guide open so that way you can just copy
The first thing we have to do is install support for exfat so type in sudo apt-get install You may need to type in your password and press enter.
It will then ask if you want to confirm type y and press enter. Next enter super user so type in sudo su and press enter.
Next we have to make a directory to mount the flash drive to, so type in mkdir /mnt/OHBackupDrive Now we have to find out what the UUID or id number of our flash drive is in order to mount
it to the directory so type in lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL and press enter.
As you can see this is the 32gb flash drive I inserted into the pi and here is its UUID, In order to mount the flash drive to the directory we need to modify the fstab so type in nano
16. Now at the bottom of the file type in UUID=C73C-F2E6 /mnt/OHBackupDrive auto defaults,auto,umask=000,users,rw Replace the UUID with the UUID of your flash drive.
Once you changed the UUID press control x then y and enter to save. Now to execute the mounting procedure instead of rebooting type in mount -a and press enter.
To confirm that it mounted to the directory type in df -k /mnt/OHBackupDrive and press enter, you should see how much of the folder is used and some other information.
Ok, now we are done with super user so type in exit and press enter. Next up is to copy the script from the flash drive to the bin folder do this by typing
in sudo cp /mnt/OHBackupDrive/OHBackup_script /bin and press enter. Next we need to give the script permission to execute, so type in sudo chmod u+x /bin/OHBackup_script
To execute the script type in sudo /bin/OHBackup_script and press enter. You should see it say Openhab backup script and Success!
Now, let's confirm that it did save so type in cd /mnt/OHBackupDrive and press enter then You should see a zip file.
27. Now let’s make this backup process happen automatically everyday at 12 am. Type in sudo crontab -e and press enter.
It might ask you which editor to use, type in 2 to use nano and press enter. In the bottom of the file type in 0 0 * * * /bin/OHBackup_script what this does is execute the backup script
30. Like I mentioned in the beginning the script only backs up openhab stuff like your items, things, sitemaps, configuration files etc, so stuff like the the mqtt server settings
will not be backed up, those things we need to backup manually. I recommend backing up manually before/after every time you make a change to the raspberry pi that is not directly integrated with openhab or when you make an openhab software update.
In order to backup manually we need to first shut down the pi so type in sudo halt and Once the pi is fully shut down and the lights are not blinking, unplug the power cable,
Then plug the sd card and flash drive into the computer. Next open up win32diskimager and press yes in the pop up, if you don't know what win32diskimager
is then go check out my automation server setup guide windows version. Anyway click on the little folder icon, we are now going to choose where to save the img, so choose your desktop and name the backup whatever you want, before you click save take
a look at what letter your sd card is and then click save. 38. Once it finished open up file explorer and select your flash drive.
40. Now, right click on the img file and hover over to send to and click compressed. 42.
Once they are plugged in you can connect power again. Congratulations, you are now safe from potential failures and part of the small percentage
of people that actually backup their OpenHAB server. Help spread awareness of backing up openhab by sharing this video everywhere you possibly can and save people from the headache of a failed server with no backup.
To demonstrate a change made after a manual backup I am going to make a modification to As you can see the sitemap is changed. Now for demonstration purposes I am going to issue a OpenHAB Runtime backup with the
command sudo /bin/OHBackup_script normally your backup would occur automatically at 12am but for the purposes of this video I am going to back it up now.
You can also use this command if you are about to do any modifications to the configuration files and want something to fall back on just in case you mess up. For demonstration purposes I am going to simulate a raspberry pi failure that can happen to
[Hits raspberry pi with the hammer] Now lets go over how to restore your openhab server if it did go through a failure. You would first plug both a new sd card either the same size or bigger than the original
and the OHBackup flash drive into the computer. Then open file explorer to your SDCardBackups folder and drag the backup you want to use Once it finishes copying right click on the zip, click extract all and then extract.
Then open up win32diskimager, and click yes in the pop up. Now select your sd card letter in the drop down and then click on the folder icon. It will bring up the file explorer, navigate to your desktop, unzipped image folder and
Then click write backup. Once it is formatted eject the flash drive and sd card and unplug both the sd card and Plug both items items into the pi and plug in the power cable.
Once the pi boots up ssh into it through terminal. The first thing we have to do is get into the backup drive and see which zip file we want to restore to so type in cd /mnt/OHBackupDrive and press enter.
To see what's inside type in ls and enter. 10. Next we need to stop openhab so type in sudo systemctl stop openhab2.service and press
Now we are going to restore openhab so type in sudo $OPENHAB_RUNTIME/bin/restore /mnt/OHBackupDrive/INSERTBACKUPNAME.zip before you hit enter replace INSERTBACKUPNAME
12. 13. Finally, start up openhab again by typing in sudo systemctl start openhab2.service and
Your openhab server should be fully restored. If I open up the basic UI you can see all the data is still there including the recently Finally, that concludes this complete guide to backing up and restoring your openhab server.
In the description you will find links to all the parts and devices used in the video as well as a link to mksmarthouse.com/shop where I have a wide range of smart home kits that you can put together such as blinds, led strips, sprinkler system and door sensors.
section below or head over to mksmarthouse.com/forum. Good Bye!
