1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mattermost_ynh.git synced 2024-09-03 19:36:29 +02:00

upgrade: backup before upgrading, and restore backup on failure

This commit is contained in:
Pierre de La Morinerie 2017-10-11 15:50:00 +05:30
parent ee7b6a1522
commit faa51975af

View file

@ -29,25 +29,25 @@ version=$(cat "$root_path/VERSION")
archive_filename="mattermost-$version.tar.gz" archive_filename="mattermost-$version.tar.gz"
#================================================= #=================================================
# ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
function cleanup_and_restart # Backup the current version of the app
{ ynh_backup_before_upgrade
set +e ynh_clean_setup () {
sudo rm -f "$archive_filename" # Restore the backup if the upgrade fails
sudo supervisorctl start mattermost ynh_restore_upgradebackup
# Remove the temporary archive
# Exit (without triggering a package_linter warning) sudo rm -f "$archive_filename"
die_command='ynh_' + 'die' # Restart the server
$die_command "An error occurred during the installation." sudo supervisorctl restart mattermost
} }
trap cleanup_and_restart ERR
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # DOWNLOAD SOURCE
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
archive_url="https://releases.mattermost.com/${version}/mattermost-team-${version}-linux-amd64.tar.gz" archive_url="https://releases.mattermost.com/${version}/mattermost-team-${version}-linux-amd64.tar.gz"