We investigate the build-up of the galactic dynamo and subsequently the origin of a magnetic driven outflow. We use a set-up of an isolated disc galaxy with a realistic circum-galactic medium (CGM). We find good agreement of the galactic dynamo with theoretical and observational predictions from the radial and toroidal components of the magnetic field as function of radius and disc scale height. We find several field reversals indicating dipole structure at early times and quadrupole structure at late times. Together with the magnetic pitch angle and the dynamo control parameters Rα, Rω, and D, we present strong evidence for an α2-Ω dynamo. The formation of a bar in the centre leads to further amplification of the magnetic field via adiabatic compression which subsequently drives an outflow. Due to the Parker instability the magnetic field lines rise to the edge of the disc, break out, and expand freely in the CGM driven by the magnetic pressure. Finally, we investigate the correlation between magnetic field and star formation rate. Globally, we find that the magnetic field is increasing as function of the star formation rate surface density with a slope between 0.3 and 0.45 in good agreement with predictions from theory and observations. Locally, we find that the magnetic field can decrease while star formation increases. We find that this effect is correlated with the diffusion of magnetic field from the spiral arms to the interarm regions which we explicitly include by solving the induction equation and accounting for non-linear terms.