<div dir="ltr">Any reason why you don't want to run Mnesia instead and use it's backup and restore functions ? </div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 27, 2014 at 1:39 PM, Alexei Sholik <span dir="ltr"><<a href="mailto:alcosholik@gmail.com" target="_blank">alcosholik@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi all,<br><br></div>I've been thinking about and googling for ways to back up a running dets database (i.e. with no interruption to the main service using it) and here's what I have come up with so far.<br>


<br></div>1. On the same node that currently has the dets file open, create an empty ETS table and another empty dets file. Call dets:to_ets and then ets:to_dets to write to the new dets file. After closing the latter file it will be safe to move it to the backup location.<br>


<br></div><div>2. Open a new dets file and use dets:bchunk on the production file in combination with dets:init_table. I wasn't sure if init_table would iterate over the original dets file automatically (iow, handling all the continuations before receiving '$end_of_table').<br>


</div><div><br></div><div>3. Use one of the traversal functions to copy elements from one dets file to another one.<br><br></div><div>I first thought the 1st approach to be the most efficient one (provided there is enough free RAM for the temporary ETS table). However, if bchunk() works like this with init_table():<br>


<br></div><div>     TableSize = dets:info(my_table, size),<br></div><div>     dets:open_file(new_table, [{min_no_slots, TableSize}]), <br></div><div>     InitFun = dets:bchunk(my_table, start),<br></div><div>     dets:init_table(new_table, InitFun, [{min_no_slots, TableSize}, {format, bchunk}]),<br>


</div><div>     dets:close(new_table).<br><br></div><div>then this 2nd approach looks like the best candidate. Here I could also use 'ram_file' option for new_table to speed up the subsequent init_table() call provided there is enough free RAM. Is this correct?<br>


<br></div><div>I will appreciate anyone pointing out mistakes in my reasoning above.<br><br>Thanks<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div><div><div>
<div><br>-- <br>Best regards<br>Alexei Sholik
</div></div></div></div></font></span></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>