TubeSum ← Transcribe a video

Complete Guide OpenHAB 2 Backup And Restore : MAC 2018

0h 13m video Published Mar 31, 2018 Transcribed Aug 1, 2026 M MK-SmartHouse
Intermediate 7 min read For: Home automation enthusiasts and OpenHAB users with basic Linux command-line experience who want to implement a reliable backup strategy.
AI Trust Score 70/100
⚠️ Average / Some Fluff

"Delivers a thorough, step-by-step guide that matches the title's promise, though some parts are padded with promotional content."

AI Summary

This video provides a comprehensive guide on backing up and restoring an OpenHAB 2 server running on a Raspberry Pi, specifically using a Mac. The backup strategy involves an automated daily backup of OpenHAB configuration files to an external flash drive, complemented by manual SD card backups for the entire system. The tutorial covers setup, automation, and restoration procedures.

[00:40]
Backup Strategy Overview

The backup method uses an external flash drive plugged into the Raspberry Pi. Every day, the Pi automatically backs up the OpenHAB configuration to the drive. Additionally, a manual SD card backup is performed to cover non-OpenHAB system changes.

[01:10]
Required Items

Items needed: a fully set up Raspberry Pi running OpenHAB (any model), a Mac computer, an SD card reader, and a flash drive of the same size as the SD card (e.g., 32GB).

[02:44]
Preparing the Flash Drive

Plug the flash drive into the Mac, open Disk Utility, select the drive, erase it, name it 'OHBACKUP', and format as ExFat.

[03:21]
Downloading the Backup Script

Download the OHBackup_script from the website, unzip it, and copy the script to the flash drive. Then eject the drive and plug it into the Raspberry Pi.

[04:11]
Setting Up the Pi

SSH into the Pi, install exfat support with 'sudo apt-get install exfat-fuse exfat-utils', enter super user, create mount directory '/mnt/OHBackupDrive', find the flash drive UUID with 'lsblk', and add an entry to fstab for auto-mount.

[06:14]
Installing and Running the Script

Copy the script to /bin, make it executable with 'chmod u+x', and run it with 'sudo /bin/OHBackup_script'. Confirm backup by checking for a zip file in the mount directory.

[07:13]
Automating Daily Backups

Edit crontab with 'sudo crontab -e' and add '0 0 * * * /bin/OHBackup_script' to run the backup daily at midnight.

[08:12]
Manual SD Card Backup

Shut down the Pi, remove the SD card and flash drive, connect them to the Mac, use ApplePiBaker to create a backup image, compress it, and store it in a folder named 'SDCardBackups' on the flash drive.

[10:23]
Restoring OpenHAB

To restore, connect a new SD card and the backup flash drive to the Mac, use ApplePiBaker to write the backup image to the SD card, then boot the Pi. SSH in, stop OpenHAB, run the restore command with the appropriate zip file, and start OpenHAB again.

By following this guide, you can protect your OpenHAB server from data loss through automated daily backups and manual SD card backups, ensuring you can restore your system quickly after a failure.

Mentioned in this Video

Tutorial Checklist

1 02:44 Plug flash drive into Mac, open Disk Utility, erase and format as ExFat, name it OHBACKUP.
2 03:21 Download OHBackup_script from website, unzip, copy to flash drive, eject, and plug into Raspberry Pi.
3 04:11 SSH into Pi, install exfat support: sudo apt-get install exfat-fuse exfat-utils
4 04:46 Enter super user: sudo su, create mount directory: mkdir /mnt/OHBackupDrive
5 05:04 Find flash drive UUID: lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL
6 05:33 Edit fstab: nano /etc/fstab, add line: UUID=YOUR_UUID /mnt/OHBackupDrive auto defaults,auto,umask=000,users,rw
7 05:47 Save and mount: press Ctrl+X, Y, Enter, then run: mount -a
8 06:14 Exit super user: exit, copy script: sudo cp /mnt/OHBackupDrive/OHBackup_script /bin
9 06:27 Make script executable: sudo chmod u+x /bin/OHBackup_script
10 06:46 Run script: sudo /bin/OHBackup_script
11 07:13 Automate daily backup: sudo crontab -e, add line: 0 0 * * * /bin/OHBackup_script
12 08:12 Manual SD card backup: shut down Pi, remove SD and flash drive, connect to Mac, use ApplePiBaker to create backup, compress, store in SDCardBackups folder.
13 10:23 Restore: write backup image to new SD card with ApplePiBaker, boot Pi, SSH in, stop OpenHAB: sudo systemctl stop openhab2.service
14 12:20 Restore OpenHAB: sudo $OPENHAB_RUNTIME/bin/restore /mnt/OHBackupDrive/INSERTBACKUPNAME.zip
15 12:32 Start OpenHAB: sudo systemctl start openhab2.service

Study Flashcards (5)

What is the purpose of the OHBackup_script?

easy Click to reveal answer

It automatically backs up OpenHAB configuration files daily at 12am and deletes backups older than 30 days.

03:21

What command is used to find the UUID of the flash drive?

medium Click to reveal answer

lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL

05:04

What line is added to crontab to run the backup daily at midnight?

medium Click to reveal answer

0 0 * * * /bin/OHBackup_script

07:27

What command is used to restore OpenHAB from a backup?

hard Click to reveal answer

sudo $OPENHAB_RUNTIME/bin/restore /mnt/OHBackupDrive/INSERTBACKUPNAME.zip

12:20

What tool is used on Mac to create an SD card backup?

easy Click to reveal answer

ApplePiBaker

08:27

💡 Key Takeaways

🔧

Automated Daily Backups

This is the core strategy: a flash drive and cron job ensure OpenHAB configs are backed up daily without manual intervention.

00:40
🔧

Cron Job for Automation

The crontab entry '0 0 * * *' is a simple yet powerful way to automate backups, a key principle for system reliability.

07:13
🔧

Manual SD Card Backup

This step covers the entire system, not just OpenHAB, ensuring complete recovery after a total failure.

08:12
🔧

Restoration Process

The restore procedure is clearly demonstrated, giving users confidence to recover from a failure.

10:23

[00:00] 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 a mac.

[00:12] [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

[00:27] 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

[00:40] 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

[00:55] 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

[01:10] 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

[01:24] 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

[01:43] 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 MAC OS or OS X, if you have a windows computer then

[01:59] check out my guide where I do this same guide except using a windows computer. 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

[02:16] 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.

[02:28] 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

[02:44] 1. The first thing we have to do is plug the flash drive into the computer. Next go to spotlight, type in disk utility and press enter.

[02:56] In the left column click on your flash drive. The next part we are about to do will erase everything on the flash drive so make sure 4.

[03:09] In the name box type in OHBACKUP and in the format select ExFat. Next we need to head over to the written version of this guide on my website, link is in the

[03:21] 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.

[03:38] 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.

[03:54] 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

[04:11] Now open up terminal on your mac and ssh into the pi. 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

[04:28] 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.

[04:46] 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

[05:04] it to the directory so type in lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL and press enter.

[05:16] 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

[05:33] 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.

[05:47] 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.

[06:01] 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.

[06:14] 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

[06:27] 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

[06:46] To execute the script type in sudo /bin/OHBackup_script and press enter. You should see it say Openhab backup script and Success!

[07:00] Now, let's confirm that it did save so type in cd /mnt/OHBackupDrive and press enter then You should see a zip file.

[07:13] 27. Now let’s make this backup process happen automatically everyday at 12 am. Type in sudo crontab -e and press enter.

[07:27] 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

[07:40] 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

[07:57] 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.

[08:12] 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,

[08:27] Then plug the sd card and flash drive into the computer. Next open up applepibaker, if you dont know what apple pi baker is then go check out my

[08:39] automation server setup guide mac version. Anyway type in your admin password for your computer and press ok. In the pi crust section select your sd card and then click create backup.

[08:52] It will then ask what to name it also where to save, name it what you want and choose 39. Right click, create a new folder, and name it SDCardBackups.

[09:08] Now, right click on the img file and click compress. Once it finished compressing drag the zip file from your desktop to the SDCardBackups Once it copies over you are completely done backing up your automation server.

[09:24] 43.You can now eject the flash drive as well as the sd card and plug them back into the Once they are plugged in you can connect power again. Congratulations, you are now safe from potential failures and part of the small percentage

[09:39] 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.

[09:55] 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

[10:10] 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.

[10:23] 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

[10:37] [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

[10:53] and the OHBackup flash drive into the computer. Then open finder to your SDCardBackups folder and drag the backup you want to use to your Once it finishes copying double click on the zip file to expand it into a proper img file.

[11:09] Then open up apple pi baker, type in your admin password and press ok. Now click on your sd card in the Pi-Crust Section. In the Pi-Ingredients section click on the 3 dots.

[11:22] It will bring up a mini finder, navigate to your desktop and click on the img file we 6. Once it is formatted eject the flash drive and unplug both the sd card and flash drive.

[11:41] 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

[11:53] want to restore to so type in cd /mnt/OHBackupDrive and press enter. To see what's inside type in ls and enter. I am going to backup to the latest zip file which is this one.

[12:07] 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

[12:20] sudo $OPENHAB_RUNTIME/bin/restore /mnt/OHBackupDrive/INSERTBACKUPNAME.zip before you hit enter replace INSERTBACKUPNAME 12.

[12:32] 13. Finally, start up openhab again by typing in sudo systemctl start openhab2.service and Your openhab server should be fully restored.

[12:47] 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.

[13:01] 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.

[13:17] section below or head over to mksmarthouse.com/forum. Good Bye!

More from MK-SmartHouse

View all

⚡ Saved you 0h 13m reading this? Transcribe any YouTube video for free — no signup needed.