Turns out this can be done pretty easily:
#!/usr/bin/env escript
change_node_name(Mod, Source, Target) ->
% Change this to whatever you want the new node list to be,
% with however many nodes, whatever names, etc.
ChangeNodes =
fun(_Nodes) ->
['[email protected]','[email protected]']
end,
Convert =
fun({schema, db_nodes, Nodes}, Acc) ->
{[{schema, db_nodes, ChangeNodes(Nodes)}], Acc};
({schema, version, Version}, Acc) ->
{[{schema, version, Version}], Acc};
({schema, cookie, Cookie}, Acc) ->
{[{schema, cookie, Cookie}], Acc};
({schema, Tab, CreateList}, Acc) ->
Keys = [ram_copies, disc_copies, disc_only_copies],
OptSwitch =
fun({Key, Val}) ->
case lists:member(Key, Keys) of
true -> {Key, ChangeNodes(Val)};
false-> {Key, Val}
end
end,
{[{schema, Tab, lists:map(OptSwitch, CreateList)}], Acc};
(Other, Acc) ->
{[Other], Acc}
end,
mnesia:traverse_backup(Source, Mod, Target, Mod, Convert, switched).
main(_Args)->
change_node_name(mnesia_backup,"/tmp/source-backup","dest-backup").