mirror of
https://github.com/YunoHost-Apps/mattermost_ynh.git
synced 2024-09-03 19:36:29 +02:00
Merge pull request #92 from YunoHost-Apps/fix-upgrade-failure
upgrade: attempt to restore backup only if it was correctly saved
This commit is contained in:
commit
652c3a8251
1 changed files with 22 additions and 6 deletions
|
@ -36,16 +36,32 @@ logs_path="/var/log/$app"
|
|||
#=================================================
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
# (NB: `tee` uses process substitution rather than a pipe,
|
||||
# to avoid spawning a subshell that would not save global
|
||||
# variables defined by `ynh_backup_before_upgrade`.)
|
||||
ynh_backup_before_upgrade > >(tee "upgrade.log")
|
||||
# Ensure the backup can be restored
|
||||
if grep -q "mattermost: Warning$" "upgrade.log"; then
|
||||
can_restore_backup=false
|
||||
else
|
||||
can_restore_backup=true
|
||||
fi
|
||||
|
||||
# If the upgrade fails…
|
||||
ynh_clean_setup () {
|
||||
if [ "$can_restore_backup" = true ]; then
|
||||
# Stop attempting to restart the app
|
||||
if $(sudo systemctl -q is-active "$app"); then
|
||||
sudo systemctl stop "$app"
|
||||
fi
|
||||
# Restore the backup
|
||||
ynh_restore_upgradebackup
|
||||
|
||||
else
|
||||
# Backup restoration is not available:
|
||||
# let's try at least to restart the server.
|
||||
sudo systemctl start "$app"
|
||||
fi
|
||||
}
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
|
|
Loading…
Reference in a new issue