[erlang-questions] Why doesn't backup/restore work for me?

Dan Gudmundsson dgud@REDACTED
Tue Jun 2 09:14:34 CEST 2009


Because you don't have anything in the backup file.

For some strange reason, I guess it is because ram_tables are supposed
to be temporary, mnesia:backup() don't backup ram_copies tables.

Read up on mnesia:activate_checkpoint/1 instead.

/Dan

Sergey Samokhin wrote:
> Hello.
> 
> After mnesia:restore/2 has been applied, I don't see the records
> restored from backup made by mnesia:backup/1 (which is supposed to
> create complete backup of all the table if I don't make a mistake).
> 
> I must have missed something significant, but I don't see what exactly.
> 
> Here is example:
> 
> %%%%%%%%%%%%
> test() ->
>     mnesia:start(),
> 
>     mnesia:create_table(foo, []),
>     [mnesia:dirty_write({foo, N, -N}) || N <- lists:seq(1, 100)],
>     io:format("# ~p records inserted~n", [mnesia:table_info(foo, size)]),
> 
>     mnesia:backup(backup_file),
> 
>     mnesia:clear_table(foo),
> 
>     mnesia:restore(backup_file, []),
> 
>     io:format("# ~p records restored~n", [mnesia:table_info(foo, size)]).
> %%%%%%%%%%%%
> 
> Results:
> 
> 1> test:test().
> # 100 records inserted
> # 0 records restored
> 
> Thanks.
> 


More information about the erlang-questions mailing list