Sidi_Mohammed
Mnesia Backup traverse does not find :db_nodes field
Hello,
I have mnesia database which I want to change its node name, I have followed erlang official documentation and end up by this code which I run on :firstnode@host:
:mnesia.stop()
:mnesia.start()
Process.sleep(200)
:mnesia.backup('backup.bup')
change_node_name(:mnesia_backup, :firstnode@host, :secondnode@host, 'backup.bup', 'new_backup.bup')
###########
defp change_node_name(mod, from, to, source, target) do
switch =
fn(node) when node == from ->
to
(node) when node == to ->
throw({:error, :already_exists})
(node) -> node
end
convert =
fn({:schema, :db_nodes, nodes}, acc) ->
{[{:schema, :db_nodes, :lists.map(switch, nodes)}], acc}
({:schema, :version, version}, acc) ->
{[{:schema, :version, version}], acc}
({:schema, :cookie, cookie}, acc) ->
{[{:schema, :cookie, cookie}], acc}
({:schema, tab, create_list}, acc) ->
keys = [:ram_copies, :disc_copies, :disc_only_copies]
opt_switch =
fn({key, val}) ->
case :lists.member(key, keys) do
true ->
{key, :lists.map(switch, val)}
false->
{key, val}
end
end
{[{:schema, tab, :lists.map(opt_switch, create_list)}], acc}
(other, acc) ->
{[other], acc}
end
:mnesia.traverse_backup(source, mod, target, mod, convert, :switched)
end
And when trying to restore the new backend from :secondnode@host, the database still remote.
I did a lookup inside this code, the most important part is {:schema, :db_nodes, nodes} however this clause has never been matched, also (other, acc) has not matched, the only matched clause is {:schema, tab, create_list}, so any help please ? thank you.
Popular in Questions
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
Hey,
I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
In AR this is so simple
@articles = current_user.articles
How to do in Ecto?
def index(conn, _params) do
current_user = conn.assig...
New
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217
Let’s say I have a map with required and optional k...
New
Other popular topics
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I'm writing a test for one of t...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
Hi everyone,
One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New








