processone / docker-ejabberd

Set of ejabberd Docker images
94 stars 77 forks source link

Unable to restore from backup #96

Closed sw-dev1 closed 1 year ago

sw-dev1 commented 1 year ago

Tried :

Create a binary backup from web admin console .../backup Remove container from Docker. Create new container. On web admin console .../backup choose backup file, click OK. Nothing happens, system is in the same state

Tried also

docker exec -it ejabberd bin/ejabberdctl restore /home/ejabberd/backup/ejabberd.backup

Same as above

badlop commented 1 year ago

You can simply use the same mnesia spool dir from the old container in the new one, which looking at the ecs container image documentation, it's in the path /home/ejabberd/database/

sw-dev1 commented 1 year ago

Thanks, but it seems that it is not enough to only copy the database directory. Additionally the whole process "Change Computer Hostname" from https://docs.ejabberd.im/admin/guide/managing/#advanced-configuration needs to be performed. Is this the intended way of restoring from backup?

badlop commented 1 year ago

Ah, right, the erlang node name in this container image is random, so each time you create a new container, a new name is used, and the mnesia database is locked to that name.

This is changed starting in the ejabberd 23.04 docker image: from now, the name will be by default ejabberd@localhost, and that will allow to reuse the database dir from one container to another one.

In your case, you have the mnesia database with a random erlang node name stored in it, you have two options:

A) Change the Computer Hostname that is stored in the mnesia files, as documented in Change Computer Hostname

B) Or you can simply create the container providing the desired erlang node name using ERLANG_NODE_ARG, which you should provide the old one. This is mentioned in the ejabberd 23.04 release notes

plantroon commented 1 year ago

I had a similar problem to this one, where recreating the container (as it is ephemeral in docker-compose) would cause it to get a different hostname and therefore the erlang node name would change and create a new database instead of using the old one. I fixed it by setting hostname of the container in docker-compose file.

Now that I pulled 23.04 it broke again because of using hardcoded localhost instead of the hostname. Why was the hardcoded ejabberd@localhost chosen instead of for example updating the docs to have "hostname" defined in docker-compose files?

badlop commented 1 year ago

using hardcoded localhost instead of the hostname.

Hardcoded? It's fixed instead of dynamic (https://github.com/processone/docker-ejabberd/commit/f81905d5e315d2eb813a715b51d4a8351a7d4e6b), i would say that is softcoded, not hardcoded: it can be changed using ERLANG_NODE_ARG when calling docker, or in docker-compose.yml (as explained in the 23.04 release notes) right?

Why was the hardcoded ejabberd@localhost chosen instead of for example updating the docs to have "hostname" defined in docker-compose files?

The original conversation is linked in the issue that is linked in the commit that changed this.