Backup/Restore scripts for Linux and MacOS

Hi,

one question on my side.
I’m currently running (an old) netinst of openhabian with OH 2.1.0 stable.
I want to install on a new SD card with openhabian 1.4 (an OH 2.2.0)
How can I create a backup of old installation?
How can I restore on new installed sd card?

Thanks a lot

helmar

Just follow

http://docs.openhab.org/installation/linux.html#backup-and-restore

Thanks, but I don’t have
$OPENHAB_RUNTIME/bin/backup

Regards

Helmar

Backup script: https://github.com/openhab/openhab-distro/blob/master/distributions/openhab/src/main/resources/bin/backup

Restore script: https://github.com/openhab/openhab-distro/blob/master/distributions/openhab/src/main/resources/bin/restore

I’d be tempted to update to openhab 2.2 first and then use the backup script that will appear in the runtime folder. Just to make sure hat the update scripts finds the correct paths.

I’ve had similar problems to most of you. I’ve moved from rpi to a server but I’m still using the openhabian script to update and maintain the system. The first update didn’t work great so I went through various other update and tried again. This time it was worse, habpanel wouldn’t even open up. I then used the option to change to stable from unstable, etc. which fixed most things. Still have weird shit going but I haven’t sorted out the logs to narrow down the issue.

I cannot find the backup zip…

Using '/etc/openhab2' as conf folder...
Using '/var/lib/openhab2' as userdata folder...
Making Temporary Directory
Copying configuration to temporary folder...
Removing unnecessary files...
Backup Directory is inside userdata, not including in this backup!
Zipping folder...
Removing temporary files...
Success! Backup made in Backup20171223

$OPENHAB_BACKUPS <-- it is empty

You should find the backup zip file in /var/lib/openhab2/backups.

Will there be any chance at any time that we can handle all maintenance tasks from inside the (Paper) UI?
This would include updates as well as Backup/Restore jobs?

1 Like

Hi,

Sry, I am new with Openhab and docker…
If I am correct, if I am using using docker I just need to copy the data stored in the mounted volumes?
So in this case /Opt/Openhab

Hi,

great script, woks like a charm on a standard openhabian installation. For me it would be nice to be able to exclude certain folders from the copy (before they are copied), as I’ve mounted a picture folder into the html directory to be able to access them, but they shouldn’t go into the backup to keep it as small as possible (and also it’s too big to be copied on the sd card for the backup). Would it be possible to add kind of an exclude file?

thx

Hello,

I’m having trouble upgrading to 2.2 (sudo runtime doesn’t work) so I thought I could backup my 2.1 and reinstall 2.2 from scratch. How do I do this backup/restore given the new backup/restore scripts in 2.2?

Many thanks!

Three thoughts on this:

  1. on which platform do you run openHAB 2.1?
  2. do you want to switch platform or just upgrade?
  3. did you configure someting outside the openHAB-context on the machine you’re running oh2 from?
  4. did you use PaperUI for configuration or file-based for all configuration?

ad 1)
if you run on Debian/Rapbian/Ubuntu and installed with apt, you should easily have an sudo apt-get update && sudo apt-get upgrade to upgrade to 2.2 - if you on openHABian, you could also just use sudo openhabian-config

ad 2)
when switching, you have to backup your configuration and restore it on the new one

ad 3)
if you didn’t configure somethin outside of openHAB2 (e.g. scripts or stuff on the OS of the machine, not within openHAB-configuration), you just have to backup the configuration and can easily restore virtually on every other 2.2 instance of openHAB

ad 4)
if you configured in PaperUI, be sure not only to backup Things/Items/Rules/… but also the PaperUI-database as described here in the thread.

finally, I’m not sure, what you mean with “new backup/restore scripts in 2.2”? the underlying structure of the files didn’t Change between 2.1 and 2.2 - what came with 2.2 is the ability to use the backup/restore script out-of-the-box…?
So, if you can’t upgrade to 2.2, you need to backup your files independently from the new 2.2 backup/restore functionality. You can then after upgrading use the new scripts.

finally: I think you should find the issue, which prevents you from upgrading in the first place? :wink:

Hi,

Is it possible to redirect /tmp to another location when the backup is being generated?

I’m running on a PI3 but /tmp is mounted as a very small tmpfs as I’m mounting other tmpfs file systems and memory is a premium, the backup generates files under /tmp before combining into the zip file but /tmp runs out of space before this can be completed.

if we could perhaps do something like the following that would help.

TMP_FS=/<another location>; $OPENHAB_HOME/runtime/bin/backup

or 

TMP_FS=/<another location>; openhab-cli backup <filename>

Regards

Kevin

Thank you for the reply, Thomas

I’m on MacOS and I just want to upgrade. I only have configurations within openHAB, mainly in Paper IU and HabPanel, but also some in persistence.

I will look in the thread for upgrade issues to see if I manage to solve it. Otherwise restoring my configurations seems so simple that I might as well install 2.2 from scratch.

What I meant with the new scrips in 2.2 was if I would be able to follow the instruction for restoring in 2.1 to restore a 2.1 backup in 2.2. I’m not sure if I understood how this should be done from your reply. How do I backup my 2.1 files independently in 2.2 backup/restore functionality?

Thanks

I don’t know the paths within MacOS, you’ll have to see in the sources what paths there are - or somebody here could help you.
there are basically two main directories, you must backup:

  • OPENHAB_USERDATA: that’s where your UI-related configuration is held
  • OPENHAB_CONF: that’s where your own items, sitemaps and stuff is Held
    be sure, you have both in you backup and after having switched to 2.2 that’s where you should restore them.

Thanks again!

There’s a small typo in the backup script:

When running:

    echo "Set $OPENHAB_BACKUPS to change the default backup directory."
    echo "Set $OPENHAB_BACKUPS_TEMP to change the default backup temporary directory."

You’ll see the environment variables’ value, no their names. The dollar sign should be escaped:

    echo "Set \$OPENHAB_BACKUPS to change the default backup directory."
    echo "Set \$OPENHAB_BACKUPS_TEMP to change the default backup temporary directory."

I’d probably report the current values of these environment variables, so I’d recommend rewriting those lines as follows:

    echo "Default backup directory: '$OPENHAB_BACKUPS'"
    echo "Set \$OPENHAB_BACKUPS to change the default backup directory."
    echo "Default backup temporary directory: '$OPENHAB_BACKUPS_TEMP'"
    echo "Set \$OPENHAB_BACKUPS_TEMP to change the default backup temporary directory."

When invoking, you should run it as root:

[17:43:16] openhabian@openHABianPi:/usr/share/openhab2$ sudo ./runtime/bin/backup --full

@shutterfreak, rather than in the forum, something like this should be reported in GH. The backup/restore scripts are in openhab-distro, which is linked to in the OP. You may want to consider submitting a PR too… this one wouldn’t even need an IDE, and could be done completely through GH.

Instead of escapes, brackets should be used, e.g. echo "Set ${OPENHAB_BACKUPS} to change the default backup directory."

I hope I did it correctly: Issue 894: [backup/restore] unescaped environment variables

2 Likes