improve restore and logging

This commit is contained in:
buanet
2020-01-04 21:00:23 +01:00
parent ce10e991f7
commit d5a1bda9b4

View File

@@ -100,38 +100,38 @@ echo "----- Step 2 of 5: Detecting ioBroker installation -----"
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..60})"
echo ' ' echo ' '
if [ `ls -1a|wc -l` -lt 3 ] files=(/opt/iobroker/*)
if [ ${#files[@]} -lt 1 ]
then then
echo "There is no data detected in /opt/iobroker. Restoring initial ioBroker installation..." echo "There is no data detected in /opt/iobroker. Restoring initial ioBroker installation..."
tar -xf /opt/initial_iobroker.tar -C / tar -xf /opt/initial_iobroker.tar -C /
echo "Done." echo "Done."
else elif [ -f /opt/iobroker/iobroker ]
if [ -f /opt/iobroker/iobroker ]
then then
echo "Existing installation of ioBroker detected in /opt/iobroker." echo "Existing installation of ioBroker detected in /opt/iobroker."
else elif [ ${#files[@]} -lt 2 ]
files=(/opt/iobroker/*) then
if [ ${#files[@]} -lt 2 ]; then if tar -ztvf /opt/iobroker/*.tar.gz "backup/backup.json" &> /dev/null
if tar -ztvf /opt/iobroker/*.tar.gz "backup/backup.json" &> /dev/null; then then
echo "ioBroker Backup detected in /opt/iobroker. Restoring ioBroker..." echo "ioBroker backup file detected in /opt/iobroker. Restoring ioBroker..."
mv /opt/iobroker/iobroker_20*.tar.gz /opt/ mv /opt/iobroker/iobroker_20*.tar.gz /opt/
tar -xf /opt/initial_iobroker.tar -C / tar -xf /opt/initial_iobroker.tar -C /
mkdir /opt/iobroker/backups mkdir /opt/iobroker/backups
mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/ mv /opt/iobroker_20*.tar.gz /opt/iobroker/backups/
iobroker restore 0 iobroker restore 0
echo "Done." echo "Done."
else echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker or a valid backup file!" echo "!!!!! Please note: The sartup script restored iobroker from a backup file. !!!!!"
echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." echo "!!!!! When ioBroker will be started it will reinstall all Adapters automatically. !!!!!"
exit 1 echo "!!!!! This might be take a looooong time! Please be patient! !!!!!"
echo "!!!!! You can view installation process by taking a look at ioBroker log. !!!!!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
fi fi
else else
echo "There is data detected in /opt/iobroker, but it looks like it is no instance of iobroker!" echo "There is data detected in /opt/iobroker but it looks like it is no instance of iobroker or a valid backup file!"
echo "Please check/ recreate mounted folder/ volume and restart ioBroker container." echo "Please check/ recreate mounted folder/ volume and restart ioBroker container."
exit 1 exit 1
fi fi
fi
fi
echo ' ' echo ' '