Even though the question is answered on MathOverflow (via a reference), I think it is worthwhile and not too hard to give a direct answer.
One should first of all note that, contrary to popular belief (cf. Invariant subalgebra of a Lie algebra under an automorphism of the Dynkin diagram, Semisimple complex Lie algebra of type $A_3$ contains a Lie subalgebra of type $B_2$ as fixed points of an automorphism.) the notion of an "automorphism of a semisimple Lie algebra $\mathfrak{g}$ induced by an automorphism of the Dynkin diagram" is not well-defined. What is true is that if one fixes one specific "pinning" / "épinglage" / set of Serre-Chevalley generators, then there is indeed a unique element of $Aut(\mathfrak{g})$ which stabilises that épinglage and induces a given automorphism of the Dynkin diagram.
This makes our task at hand rather easy, because it means that once you fix your Chevalley-Serre-generators, for any simple root $\alpha$ the automorphism $\sigma$ will necessarily send $e_\alpha$ to $e_{\sigma(\alpha)}$ by the stabilising property (otherwise it could a priori send $e_\alpha$ to $c\cdot e_{\sigma(\alpha)}$ for any constant $c$); likewise, it sends $h_\alpha$ to $h_{\sigma(\alpha)}$.
In our case this gives
$h_{\beta_1} := h_{\alpha_1}+h_{\alpha_3}+h_{\alpha_4}$
$e_{\beta_1} := e_{\alpha_1}+e_{\alpha_3}+e_{\alpha_4}$
$f_{\beta_1} := f_{\alpha_1}+f_{\alpha_3}+f_{\alpha_4}$
$h_{\beta_2} := h_{\alpha_2}$
$e_{\beta_2} := e_{\alpha_2}$
$f_{\beta_2} := f_{\alpha_2}$
as obvious candidates for generators bor the basis roots in the fixed algebra $\mathfrak{g}^\sigma$, where $\beta_1$ and $\beta_2$ form a basis of a root system of type $G_2$ (with $\beta_1$ the short root). The others are then computed from them.