[erlang-questions] Mnesia: simplest way to export/import tables across installations

Ulf Wiger <>
Mon Jul 2 18:05:23 CEST 2012


Depends a bit on how dirty you want to be, but assuming that the tables are disc_copies, you can actually simply swipe the <Tab>.DCD and <Tab>.DCL files for each table you want to move over - then drop them in the same place in the new mnesia directory (assuming schema already created), then start the new instance.

The .DCD file is a snapshot of the ets table, and the .DCL file is a set of operations on the table, updated each log dump. Thus, the pair forms a transaction-consistent view of the table (and *across tables*, if you do this on several tables at once), though not guaranteed to be the very latest. When the .DCL file grows too large, a new snapshot may be created (depending on mnesia settings).

You need to make sure that no log dump is ongoing while you do this. The only officially sanctioned way to get such a guarantee is to stop mnesia on the node in question. Before doing so, you can always call mnesia:dump_log() to ensure that you don't have a bunch of stuff still lingering in the transaction log.

BR,
Ulf W

On 2 Jul 2012, at 17:44, Daniel Dormont wrote:

> Hi all,
> 
> Since I have been unable to restore order and goodness to my Mnesia cluster as discussed in my recent thread, I've decided to start over with a fresh node. But I need to move certain data across. My question now is much simpler: what is the best way to export a table (preferably _not_ including the table definition, since it will already exist, just the set of records) in one Mnesia installation and import it into another? I'm aware that there's a risk of things being slightly out of sync and I'm willing to completely ignore transactions for the purpose of this exercise anyway.
> 
> dan
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120702/3b70d894/attachment.html>


More information about the erlang-questions mailing list