Use rename rather than unlink for a safer dbcompact

Much lower chance of losing data if process crashes in the middle of a compact operation.