YunoHost / issues

General issue tracker for the YunoHost project
72 stars 8 forks source link

Add a --replace-apps option/modal during backup restore to automatically remove already-installed-apps before restoring them #1441

Open Bugsbane opened 5 years ago

Bugsbane commented 5 years ago

I'm running Yunohost 3.6.4.6 which was a recent new install working more or less OK. When I tried to restore from a backup via the commandline though, I got the feedback below. It's on an old desktop, with a router that has hairpinning issues.

root@yuno:~# yunohost backup restore 20190912-022210
Warning: YunoHost is already installed
Do you really want to restore an already installed system? [y/N]: y
Info: Preparing archive for restoration…
Warning: cp: cannot stat '/home/yunohost.backup/tmp/20190912-022210/conf/cron/.': No such file or directory
Success! The configuration has been updated for category 'metronome'
Success! The configuration has been updated for category 'nginx'
Success! The configuration has been updated for category 'postfix'
Info: The configuration file '/etc/dnsmasq.d/01-pihole.conf' is expected to be deleted by regen-conf (category dnsmasq) but has been kept back.
Info: Restoring application writefreely…
Error: An app is already installed with the id 'writefreely'
Info: The operation 'Restore 'writefreely' from a backup archive' has failed! To get help, please share the full log of this operation using the command 'yunohost log display 20190919-132045-backup_restore_app-writefreely --share'
Info: Restoring application collaboradocker…
Error: An app is already installed with the id 'collaboradocker'
Info: The operation 'Restore 'collaboradocker' from a backup archive' has failed! To get help, please share the full log of this operation using the command 'yunohost log display 20190919-132045-backup_restore_app-collaboradocker --share'
Info: Restoring application nextcloud…
Error: An app is already installed with the id 'nextcloud'
Info: The operation 'Restore 'nextcloud' from a backup archive' has failed! To get help, please share the full log of this operation using the command 'yunohost log display 20190919-132045-backup_restore_app-nextcloud --share'
Success! Restore complete
apps: 
  collaboradocker: Error
  nextcloud: Error
  writefreely: Error
system: 
  conf_cron: Success
  conf_ldap: Success
  conf_nginx: Success
  conf_ssh: Success
  conf_ssowat: Success
  conf_xmpp: Success
  conf_ynh_certs: Success
  conf_ynh_currenthost: Success
  conf_ynh_firewall: Success
  conf_ynh_mysql: Success
  data_home: Success
  data_mail: Success
root@yuno:~# yunohost backup list
archives: 
  - 20190912-022210
  - nextcloud-pre-upgrade1
alexAubin commented 5 years ago

Hmyup it says Error: An app is already installed with the id 'nextcloud' (and similar for other apps)

Can you clarify what you expected to happen ?

Imho we should analyze in advance if apps that are going to be restored are already installed or not, and if so, stop any restoration and explain that the apps should be first uninstalled to be able to restore them :s

Bugsbane commented 5 years ago

I expected restoring a backup to restore Yunohost, it's settings and it's apps to the state they were in when the backup was made (ie with the same files, database entries and configs).

Instead it detected that the apps existed instead of restoring them from the backup, it left the apps exactly as they were.

Bugsbane commented 5 years ago

Would the correct current restore procedure be to first uninstall the app and then choose restore from the backup?

zamentur commented 4 years ago

May be we could add an option to auto remove app with same id and with same domain/path.

The option name could be --replace-apps or something like that.

Bugsbane commented 4 years ago

Id say that's a good idea on the command line. Using the web gui, personally I would (and did) just expect this to happen as default, however if you don't want to do that, you could pop up a modal asking something like "This will replace the current install of {APPNAME} with the backup. Are you sure?"

alfredo87 commented 4 years ago

This issue is very important that it should work: my host has backups stored in an USB drive and I cannot restore anything: apps fail restore even when uninstalled before restore. The errors are not clear it just fails to run the service of the app (Mattermost) after it has worked a long time restoring. What are backups used for if they cannot be restored piece by piece? It looks as if the developer created the backup scripts only for the purpose of a fresh restore/install of the whole server. If that is the case, the choices for restoring individual parts of the backup are misleading. The rule seems to be that restoring can only be done if the whole server is reinstalled and the backup puts back the settings instead of having to reinstall everything from scratch. I have several backups with apps which I do not need to restore because a newer version or themed version are up and running. So, the choice of what to restore is important (if it works!!)

Neustradamus commented 3 years ago

@Bugsbane, @alfredo87: Any news on it?

cc @alexAubin, @zamentur.

alexAubin commented 3 years ago

The initial issue regarding Error: An app is already installed with the id 'writefreely' is fixed in https://github.com/YunoHost/yunohost/commit/f9e4c96ca3de5653e109460d18edcf809371897a

YunoHost will not attempt any restore at all if any app to be restored is already installed. Right now, people are just expected to first uninstall the app before restoring the backup. This sounds scary because the final goal is not to remove the app, but technically we have to proceed this way.

I guess we could indeed improve the UX with, as ljf suggests, a --replace-apps option, and corresponding modal in the admin, but that's still to be implemented. That's more an improvement rather than a bugfix.

Regarding algredo's issue : the description looks more like a buggy app restore script rather than the UX issue being discussed here, and we can't provide any help without proper logs.

Bugsbane commented 3 years ago

Personally I don't actually see any need for UI changes. Why not just look for the same app on the same domain when the user restores, and if it exists just run the uninstaller it before the restore? Wouldn't that entirely automate what people are wanting without creating any new, unnecessary interface stuff at all?

I mean, is there really any scenario at all where the user would prefer the restore to cancel with an error rather than uninstall the app and then restore it from the backup?

alexAubin commented 3 years ago

I mean, is there really any scenario at all where the user would prefer the restore to cancel with an error rather than uninstall the app and then restore it from the backup?

Yes : for example if the admin would like to backup the currently installed version of the app, in case the restore miserably crashes and end up removing the app

Other example is related to the fact that app ids are not "unique" : if you have a server A with an installed wordpress on some domain.tld, and you'd like to migrate it to another server B already hosting a wordpress on anotherdomain.tld, you don't want to just remove the wordpress. (There's in fact no clear and obvious solution on how to handle this, but at least yunohost should not savagely removed the unrelated wordpress just because the id is the same)

zamentur commented 1 month ago

Here is a related old issue suggesting to add an uuid to the app, but the idea to use the domain (only working for webapps) as identifier could be an idea to: https://github.com/YunoHost/issues/issues/295