<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<br></div><div><div><div><div><br>-- <br>Best regards<br>Alexei Sholik
</div></div></div></div></div>