OH3 Issue with Backup / Restore

Issue with Backup / Restore OH3.0

Hey all…
I have a working OH 3.0 stable running on my PI system.
There I have done an backup which is located in the /var/lib/openhab/backups

For testing I have copied the backup file on an other “fresh” PI system which is running under OH 3.0 testing release.

When I try to restore the backup from the “stable” machine, on the “testing” machine I get a error, that the backup was unable to restore.

What is going wrong? Any idea?

BR
Scheuerer

PS: This happend with the trail to restore this backup under OH3 snapshot 2148

Do you get an error when you try to list the zip file’s content ?

7z l /var/lib/openhab/backups/openhab-backup-XX_XX_XX-XX_XX_XX.zip

Which user, which command did you use to run the restore ?

Servus Wolfgang,

ok. So the backup was done with the normal UI from OH:

I have tryed to restore with the same function, and got this error:
grafik

Then I remember, that the openhab-cli has also a function for restore, which I used.
this is the log from the error:

##########################################
openHAB restore script
##########################################

Using ‘/etc/openhab’ as conf folder…
Using ‘/var/lib/openhab’ as userdata folder…
Making Temporary Directory
Extracting zip file to temporary folder.

Backup Information:

Backup Version | 3.0.0 (You are on 3.0.0)
Backup Timestamp | 21_01_17-18_21_31
Config belongs to user | openhab
from group | openhab

Your current configuration will become owned by openhab:openhab.

Any existing files with the same name will be replaced.
Any file without a replacement will be deleted.

Okay to Continue? [y/N]: y
Moving system files in userdata to temporary folder
Deleting old userdata folder…
rm: cannot remove ‘/var/lib/openhab/persistence’: Device or resource busy
Restoring system files in userdata…
Deleting old conf folder…
Restoring openHAB with backup configuration…
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/Terrassenlicht_Relay1_AutoOff.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/tplinksmarthome_hs110_FD5580_switch.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/tplinksmarthome_hs110_80AD25_power.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/HofeinfahrtLichter_Input.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/WintergartenMarkiseButton_Status_Eingang_input.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/Gartentor_Betrieb.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/WetterInnenFlur_Battery_lowBattery.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/ONVIFIPCamera_ItemLeftAlarm.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/AnnikaFernseher_StummSchalten.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/tplinksmarthome_hs110_FC3C5F_power.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/WetterAussenGarage_Batteriespannung.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/Gartenlichterhinten_AutoOFFtimer.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/WohnzimmerHandyFenster_Power.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/Regensensor_Firmwareaktualisierungvorhanden.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/BuroKellerSteckdose_AutoAUSTimer.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/Terrassenlicht_Relay1_TimerActive.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/WetterInnenWintergarten_Batterieladung.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/HofeinfahrtButton_Status_Eingang.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/WintergartenStehlampe_SwitchLed.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/tplinksmarthome_hs110_C65341_current.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/AnnikaFernseher_Farbtemperatur.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/WintergartenMarkise_Geratetemperatur.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/WohnzimmerDreifachSteckdose_Voltage.rrd’: No space left on device
cp: cannot create regular file ‘/var/lib/openhab/persistence/rrd4j/SonstigesSteckdose_EnergyUsage.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/tplinksmarthome_hs110_C65341_rssi.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/TVUE48JS9090_Power.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/tplinksmarthome_hs110_7005DE_energyUsage.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/WetterInnenFlur_Signalstarke.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/HofeinfahrtButton_Batterieladung.rrd’: No space left on device
cp: cannot create regular file ‘/var/lib/openhab/persistence/rrd4j/tplinksmarthome_hs110_806A6E_power.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/JochenZimmerDreifachsteckdose_SwitchLed.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/AuEnlichter_Device_Uptime.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/WetterInnenWintergarten_Batteriespannung.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/tplinksmarthome_hs110_FB76F2_energyUsage.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/tplinksmarthome_hs110_FB76F2_current.rrd’: No space left on device
cp: error writing ‘/var/lib/openhab/persistence/rrd4j/tplinksmarthome_hs110_806A6E_rssi.rrd’: No space left on device
Failed to copy /tmp/openhab/restore/userdata/ to /var/lib/openhab/…
Please check /tmp/openhab/restore and replace userdata.

I have no idea why it will run, and brings this output.
Backup and restore systems has the same setting, and 16GB Micro SD in it,with a fresh 3.0 or 3.1 installation.

BR
Scheuerer

PS: The files itself can be open in WIPZIP and scroll to all the folder. Open some textfile were ok.
User is the default openhabian user.

Have a look to the diskspace that you have free on your partitions / ZRAM parttiions.
It looks like there is not enough free space left.
You did an openhab service shutdown before restoring the files ? The message about “device or resource busy” could be caused by the fact that OH still is running. I am not sure if openhabian-config takes care of shutting down OH service before.

Hello Wolfgang.

could you just short tell me, what are now the common practice to shutdown the OH3 Service an restart again in OH3. It seems to me, that is different als in OH2.5.
Could it also happend, that the build in backup and restore menue under OH 3 has NOT adapt to the OH3 needed process, files location etc?
So are in the OH3 menues for setup etc, still the OH2.5 scripts behind?

Last but not least, I don’t expect from a build in backup/restore solution, that I need the expand any partitions when doing a restore from my system. In this case I want to be a operator from the system, not a deep dive developer on Linux level.

BR
Scheuerer

sudo systemctl stop openhab

for OH2 it was the same except that the name of the service was openhab2.

sudo systemctl start openhab

No. Just the name of the service changed from openhab2 to openhab.

As it is software that could be but as there is a big community and the software is out for weeks/months now that would have been detected. There are other threads where users make use of this feature and I am not aware that I have seen complaints about this.

the scripts for OH2 and OH3 are the same just a few paths are adapted ( openhab2 is replaced by openhab ). For the majority if not even in all cases this is being detected by environment variables.
So in case there is something wrong I would expect that this needs to be investigated on your system / in your system settings.

There could be different root causes for the problem.
First please try to stop the OH service and try again.
In case the same error message that complaint about the missing space happens again then please run

df

command in a shell / logged in to the Pi system.
This will show how much space is left for the partitions on the disk as well for the ‘partitions’ on the ZRAM disk in case you use one. The space on ZRAM is limited by the size of the RAM of your system.

1 Like

Hi
I even have a problem to make a backup. I think I have a probelm with the envirements-variables.
I use ubuntu 18.04 with manual installation. Before I had OH3 installed using apt-get. But as I had problems I removed the apt-install and installed OH3 manualy (in opt/openhab). Now the variable $OPENHAB_USERDATA is set to /var/lib/openhab. So the backupscript is not working.
How can I change the variable?
Or what can I do to fix the problem?
Thanks for any hint.

Run in command line
export OPENHAB_USERDATA=opt/openhab

I think it needs to be an absolute path. So a leading / is missing.

make sure that the environment variable is set in a user profile script for all users like denominator described. There already should be a file doing that in your installation.

Many thanks for this hints. I have set the variables (so far only in the runtime-envirement).
But it still wont work:

openhab@openHAB3:/opt/openhab$ sudo runtime/bin/backup

#########################################
openHAB backup script
#########################################

Using ‘/etc/openhab’ as conf folder…
Using ‘/var/lib/openhab’ as userdata folder…
Using ‘/usr/share/openhab/runtime’ as runtime folder…
Using ‘/var/lib/openhab/backups’ as backup folder…
Writing to ‘/var/lib/openhab/backups/openhab-backup-21_01_20-08_19_07.zip’…
Configuration paths are invalid…
Try setting OPENHAB_USERDATA and OPENHAB_CONF environment variables.
openhab@openHAB3:/opt/openhab$ set | grep OPENHAB
OPENHAB_BACKUP=/opt/openhab/backups
OPENHAB_BACKUPS=/opt/openhab/backups
OPENHAB_CONF=/opt/openhab
OPENHAB_GROUP=openhab
OPENHAB_HOME=/opt/openhab
OPENHAB_HTTPS_PORT=8443
OPENHAB_HTTP_PORT=80
OPENHAB_LOGDIR=/opt/openhab/userdata/logs/
OPENHAB_RUNTIME=/opt/openhab/runtime
OPENHAB_USER=openhab
OPENHAB_USERDATA=/opt/openhab
openhab@openHAB3:/opt/openhab$

Hello Wolfgang,

I have now installed, a fresh 3.0 image stable release
After first setup, I copied the backup on the new system.
I stoped than the openhab as service.
Then I was restoring the backup file successfully.
After that I updated from the stable version to the snapshop version.

In summery everthing it worked now.

I assume, the my fault was, that the service was not stopped.

Thanks for the hint the tipp…

BR
Scheuerer

@aco,
Where in the file did you set the environment variable ?
In the backup file itself is a logic that gets the environment variable from different configuration files.
The below extract is from the ‘runtime’ backup script that is provided via the .deb package.
I doubt that there is a different version for the manual installation.
In case you would like to edit the file you need to do that after the part where it’s loaded from the files.

  ## Set path variables
  if [ -r /etc/profile.d/openhab.sh ]; then
    . /etc/profile.d/openhab.sh
  elif [ -r /etc/default/openhab ]; then
    . /etc/default/openhab
  fi

  WorkingDir="$(cd "$(dirname "$0")" && cd ../.. && pwd -P)"

  if [ -z "$OPENHAB_CONF" ];  then OPENHAB_CONF="$WorkingDir/conf"; fi
  if [ -z "$OPENHAB_USERDATA" ]; then OPENHAB_USERDATA="$WorkingDir/userdata"; fi
  if [ -z "$OPENHAB_BACKUPS" ]; then OPENHAB_BACKUPS="$WorkingDir/backups"; fi
  if [ -z "$OPENHAB_RUNTIME" ]; then OPENHAB_RUNTIME="$WorkingDir/runtime"; fi

  echo "Using '$OPENHAB_CONF' as conf folder..."
  echo "Using '$OPENHAB_USERDATA' as userdata folder..."
  echo "Using '$OPENHAB_RUNTIME' as runtime folder..."

Now I have this done in /etc/enviroment

After a reboot I can say that i’m a big step forward. Backup is done now. Only a one message, but I don’t know if its a problem or not. Not tryed to restor yet.
2021-01-20_14-07-04

You also should have that file in case you use the installation via zip file.

7z l openhab-3.0.0.zip | grep version.properties
2020-12-21 13:56:54 .....          342          166  userdata/etc/version.properties

It looks like this line is causing the problem:

  CurrentVersion="$(awk '/openhab-distro/{print $3}' "$OPENHAB_USERDATA/etc/version.properties")"

Now I see that you have userdata and conf folder set to the same directory. I think that is not correct.

1 Like

you are right! thanks for the hint.