Hi,
I’m packaging the Digiwords app for Yunohost. I made a first version that reached level 6 but as far as I understand, the current upgrade script just overwrites every file.
However, the official documentation says that upgrading the app takes indeed the form of overwriting every file but the inc/digiwords.db
file which stores in progress word clouds.
So, I’m trying to improve the upgrade script to ensure this file is not modified during upgrade.
Maybe I’m wrong, but I thought that the best way to handle it would be to restore this file from backup at the end of the upgrade.
So, I added these lines in the scripts/upgrade
file of my package :
#=================================================
# TAKE BACK THE OLD digiwords.db file
#=================================================
ynh_script_progression --message="Restoring database..." --time --weight=1
ynh_restore_file -o "$final_path/inc/digiwords.db"
But the CI test upgrade fails. Here is the full log.
This part is particularly interesting:
44713 INFO [##############++....] > Restoring database... [00h00m,06s]
44852 WARNING /usr/share/yunohost/helpers.d/backup: line 257: YNH_BACKUP_DIR: unbound variable
45417 WARNING [Error] Upgrade failed.
100946 WARNING The app was restored to the way it was before the failed upgrade.
101951 ERROR Could not upgrade digiwords: An error occurred inside the app upgrade script
101957 INFO The operation 'Upgrade the 'digiwords' app' could not be completed. Please share the full log of this operation using the command 'yunohost log share 20220224-040902-app_upgrade-digiwords' to get help
102030 WARNING Here's an extract of the logs before the crash. It might help debugging the error:
102032 INFO DEBUG - + action=reload
102034 INFO DEBUG - + line_match=
102035 INFO DEBUG - + length=20
102035 INFO DEBUG - + log_path=/var/log/php7.3-fpm/php7.3-fpm.log
102036 INFO DEBUG - + timeout=300
102037 INFO DEBUG - + '[' reload == stop ']'
102037 INFO DEBUG - + '[' reload == reload ']'
102039 INFO DEBUG - + action=reload-or-restart
102040 INFO DEBUG - + systemctl reload-or-restart php7.3-fpm
102041 INFO INFO - [##############++....] > Restoring database... [00h00m,06s]
102042 INFO DEBUG - + ynh_restore_file -o /var/www/digiwords/inc/digiwords.db
102045 INFO DEBUG - + origin_path=/var/www/digiwords/inc/digiwords.db
102046 INFO DEBUG - + dest_path=/var/www/digiwords/inc/digiwords.db
102056 INFO DEBUG - + not_mandatory=0
102057 INFO DEBUG - + local archive_path=/var/cache/yunohost/app_tmp_work_dirs/app_h7clzp95/app_folder/scripts/var/www/digiwords/inc/digiwords.db
102057 INFO DEBUG - + '[' '!' -d /var/cache/yunohost/app_tmp_work_dirs/app_h7clzp95/app_folder/scripts/var/www/digiwords/inc/digiwords.db ']'
102057 INFO DEBUG - + '[' '!' -f /var/cache/yunohost/app_tmp_work_dirs/app_h7clzp95/app_folder/scripts/var/www/digiwords/inc/digiwords.db ']'
102057 INFO DEBUG - + '[' '!' -L /var/cache/yunohost/app_tmp_work_dirs/app_h7clzp95/app_folder/scripts/var/www/digiwords/inc/digiwords.db ']'
102057 INFO DEBUG - + '[' 0 == 0 ']'
102058 INFO DEBUG - ++ ynh_exit_properly
103345 ERROR The operation 'Upgrade the 'digiwords' app' could not be completed. Please share the full log of this operation using the command 'yunohost log share 20220224-040902-app_upgrade-digiwords' to get help
I really don’t know what if wrong with my script, even if this is a conception problem, if I just forgot to set ynh_backup_dir variable (but to what?) or a syntax one…
Thanks a lot for your help.