In this paper, we study an amplify-and-forward relay network with energy harvesting (EH) source and relay nodes. Both nodes can continuously harvest energy from the environment and store it in batteries with finite capacity. Additionally, the source node is capable of transferring a portion of its energy to the relay node through a dedicated channel. The network performance depends on not only the energy arrival profiles at EH nodes but also the energy cooperation between them. We jointly design power control and transfer for maximizing the sum rate over finite time duration, subject to energy causality and battery storage constraints. By introducing auxiliary variables to confine the accumulated power expenditure, this non-convex problem is solved via a successive convex approximation approach, and the local optimum solutions are obtained through dual decomposition. Also, when channels are quasi-static and the power control values of the source (relay) node are preset to a constant, a monotonically increasing power control structure with the time is revealed for the relay (source) node with infinite battery capacity. Computer simulations are used to validate the theoretical findings and to quantify the impact of various factors, such as EH intensity at nodes and relay position on the sum rate performance.