[erlang-questions] backing up mnesia ram_copies tables

Philip Clarke send2philip@REDACTED
Thu Dec 13 12:36:52 CET 2012


Hi,

Should it be possible to make a backup of tables in mnesia if you just have
ram_copies ?

The documentation at http://www.erlang.org/doc/man/mnesia.html#backup-1 does
not seem to imply that there is any such limitation.

However when I examine the backup file created from mnesia:backup/1 it does
not seem to have any table data.

I use this simple test to check the backup.  It will fail
with {aborted,{no_exists,bup_rec,all}}.


-record(bup_rec, {key, val}).

test_cannot_restore_backup() ->
    Node = node(),
    mnesia:lkill(),
    ok = mnesia:delete_schema([Node]),
    mnesia:start(),
    mnesia:wait_for_tables([schema], infinity),

    OldBup = "old.BUP",
    file:delete(OldBup),

    CreateList = [{ram_copies, [Node]},
                  {attributes, record_info(fields, bup_rec)}],
    {atomic, ok} = mnesia:create_table(bup_rec, CreateList),
    mnesia:wait_for_tables([bup_rec], infinity),
    OldRecs = [#bup_rec{key = I, val = I * I} || I <- lists:seq(1, 10)],
    lists:foreach(fun(R) -> ok = mnesia:dirty_write(R) end, OldRecs),

    mnesia:backup(OldBup),

    mnesia:stop(),
    ok = mnesia:delete_schema([Node]),
    mnesia:start(),
    mnesia:wait_for_tables([schema], infinity),

    mnesia:restore(OldBup, [{default_op, recreate_tables}]),
    ok = mnesia:table_info(bup_rec, all).


I would like to know if I am doing the backup wrong, or if this is
something which is not supported.

Thanks
Philip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121213/bef66282/attachment.htm>


More information about the erlang-questions mailing list