23 pages, 8 captioned figures, 3 tables, authors from page 18, submitted to JHEP, figures at http://aliceinfo.cern.ch/ArtSubmission/node/3249 ; see paper for full list of authors ; The W and Z boson production was measured via the muonic decay channel in proton-lead collisions at $\sqrt{s_{\rm NN}} = 5.02$ TeV at the Large Hadron Collider with the ALICE detector. The measurement covers backward ($-4.46 10$ GeV/$c$ are determined. The results are compared to theoretical calculations both with and without including the nuclear modification of the parton distribution functions. The W-boson production is also studied as a function of the collision centrality: the cross section of muons from W-boson decays is found to scale with the average number of binary nucleon-nucleon collisions within uncertainties.