I think I’ve found a much less invasive solution: prevent displaying the database restore output in the logs; that way there’s no problem with decoding binary data.
=> Only necessary to edit the restore script.
cd /home/yunohost.backup/archives
tar xvf nc_bak2.tar apps/nextcloud/settings/scripts/restore
nano apps/nextcloud/settings/scripts/restore
Edit this line
from
ynh_mysql_db_shell < ./db.sql
to
ynh_mysql_db_shell < ./db.sql > /tmp/nextcloud_restore.log 2>&1
Then
tar --update -f nc_bak2.tar apps/nextcloud/settings/scripts/restore
yunohost backup restore bak2 --debug