This function is also duplicated verbatim in ```riak_repl```.