openhab / openhabian

openHABian - empowering the smart home, for Raspberry Pi and Debian systems
https://community.openhab.org/t/13379
ISC License
821 stars 252 forks source link

Errors when restoring from backup for OH3 #1393

Closed timbms closed 3 years ago

timbms commented 3 years ago

Issue information:

There are 2 issues with restore I wanted to report: 1 - openhabian-config cannot run restore from backup as OH3 has not directory /var/lib/openhab2/backups + whiptail --title 'Could not find backup!' --msgbox 'We could not find any configuration backup file in the storage directory /var/lib/openhab2/backups' 8 80 2 - openhab-cli restore has misleading output - Though the backup is successfully restored, it reports an error "cannot remove '/var/lib/openhab/persistence': Device or resource busy. When backups are necessary, users tend to get nervous with error messages.

[14:14:52] openhabian@openHABianDevice:/var/lib/openhab/persistence/rrd4j$ sudo openhab-cli restore /tmp/openhab-backup-21_01_06-12_26_42.zip 

##########################################
          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_06-12_26_42
 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...
Deleting temporary files...
Backup successfully restored!

System information:

I am running openhabian an raspi 4:

cat /etc/os-release [14:22:08] openhabian@openHABianDevice:/var/lib/openhab/persistence/rrd4j$ cat /etc/os-release PRETTY_NAME="Raspbian GNU/Linux 10 (buster)" NAME="Raspbian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs and uname -m.

armv7l

mstormi commented 3 years ago

1 - openhabian-config cannot run restore from backup as OH3 has not directory /var/lib/openhab2/backups

The directory that backups go to and are tried to restore from depends on the openHABian branch, yours is for the OH2 branch(es). The OH3 branch "openHAB3" uses a different dir. So either you're using the wrong openHABian branch or you want to restore OH2 config into OH3, both of which are user faults not the system's.

openhab-cli restore has misleading output - Though the backup is successfully restored, it reports an error "cannot remove '/var/lib/openhab/persistence': Device or resource busy

openhab-cli and the backup/restore scripts it runs are not a part of openhabian but of openhab-distro so you're addressing the wrong repo/maintainers, please open your issue over there. @BClark09 The dir itself a top level dir on ZRAM so cannot be removed without taking ZRAM down. pls check if you can change the restore script to just delete the contents rather than the whole directory.