mnesia restore when node name changes

Hi All,

I’m looking for some advice please. What would be the easiest way to automate the mnesia restore process when the nodename changes?

I have an ejabberd mnesia database backup file where the nodename was set to ‘ejabberd@localhost’. I want to restore this backup to a new machine where the hostname will be something like ‘ejabberd@host1’. The idea is to add a second clustered host later on.

The restore process must be automated, but I need to figure out what the old nodename was and what the new nodename will be so that I can use the built-in ejabberdctl command mnesia_change_nodename oldnodename newnodename oldbackup newbackup before calling install_fallback file.

See the attached escript for my attempted solution where I tried to restore a temp copy of the backup in order to parse the old node name. mnesia:restore or mnesia:install_fallback seems to require the nodenames to match exactly before it will extract the database backup file :frowning:

Hopefully there’s an easier solution? Thanks.


Thats correcct, but you can easily change the node name in the backup file using mnesia:traverse_backup/4. here is a code sample that literally does that.

1 Like

Yes, I believe ejabberdctl’s mnesia_change_nodename uses mnesia:traverse_backup to change the nodename. My question is how can I read the nodename from an existing backup file so that I know what oldnodename to use.

We open schema.DAT as a dets and rewrite the local node name parts in it to match the actual local node. This is done without mnesia or anything that would use mnesia started.

1 Like