The differential cross-section for the inclusive production of psi(2S) mesons in pp collisions at sqrt(s)=7 TeV has been measured with the LHCb detector. The data sample corresponds to an integrated luminosity of 36 pb-1. The psi(2S) mesons are reconstructed in the decay channels psi(2S) -> mu+ mu- and psi(2S) -> J/psi pi+ pi-, with the J/psi meson decaying into two muons. Results are presented both for promptly produced psi(2S) mesons and for those originating from b-hadron decays. In the kinematic range pT(psi(2S)) <= 16 GeV/c and 2 < y(psi(2S)) <= 4.5 we measure 1.44 +- 0.01 +- 0.12+0.2-0.4 mub for prompt psi(2S) production and 0.25 +- 0.01 +- 0.02 mub for psi(2S) from b-hadron decays, where the last uncertainty on the prompt cross-section is due to the unknown psi(2S) polarization. Recent QCD calculations are found to be in good agreement with our measurements. Combining the present result with the LHCb J/psi measurements we determine the inclusive branching fraction B(b -> psi(2S) X) = (2.73 +- 0.06 +- 0.16 +- 0.24) x 10^(-3), where the last uncertainty is due to the B(b -> J/psi X), B(J/psi -> mu+ mu-) and B(psi(2S) -> e+ e-) branching fraction uncertainties. All above results are corrected by an erratum included as an appendix.