Ukraine and Russia have agreed to a deal that would allow the resumption of exports from three Ukrainian ports.