anchor.diff:      end,
       mnesia:subscribe(system),
       ?Log("~p started as ~p!~n", [?MODULE, NodeType]),
  +
  +    % backup any existing snapshots and start new snapshoting
  +    backup_snap(),
       if SnapInterval > 0 -> erlang:send_after(SnapInterval, self(), snapshot); true -> ok end,
       {_, SnapDir} = application:get_env(imem, imem_snapshot_dir),
       SnapshotDir = filename:absname(SnapDir),
  
positive.code:     end,
      Tabs = [T || T <- mnesia:system_info(tables), re:run(atom_to_list(T), "(.*@.*)|schema") =:= nomatch],
      [(fun() ->
          % io:format(user, "snapshotting ~p~n", [T]),
          [#user_properties {
              table = T
              , last_write = Wt
              , last_snap = St
          } = Up |_] =  ets:lookup(?MODULE, T),
          LastWriteTime = timestamp(Wt),
          LastSnapTime = timestamp(St),
          %io:format(user, "~p times ~p ~p~n", [T, {LastWriteTime, LastSnapTime}, {Wt, St}]),
          if 
              LastSnapTime =< LastWriteTime ->
                  mnesia:transaction(fun() ->
                                  Rows = mnesia:select(T, [{'$1', [], ['$1']}], write),
                                  BackFile = filename:join([SnapDir, atom_to_list(T)++".bkp"]),
                                  NewBackFile = filename:join([SnapDir, atom_to_list(T)++".bkp.new"]),
                                  ok = file:write_file(NewBackFile, term_to_binary(Rows)),
                                  {ok, _} = file:copy(NewBackFile, BackFile),
                                  ?Log("snap ~p -> ~p~n", [T, BackFile]),
                                  ok = file:delete(NewBackFile)
                                 end),
                  true = ets:insert(?MODULE, Up#user_properties{last_snap = erlang:now()});
              true -> 
                  ok % no backup needed
          end
        end)()
      || T <- Tabs],
  
negative.code:     end.
  
  write(Table, Row) when is_atom(Table), is_tuple(Row) ->
      %if Table =:= ddTable -> ?Log("mnesia:write ~p ~p~n", [Table,Row]); true -> ok end,
      Result = case transaction(write,[Table, Row, write]) of
          {aborted,{no_exists,_}} ->
              % ?Log("cannot write ~p to ~p~n", [Row,Table]),
  