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