Reset backup_idx when necessary

backup_idx is incremented for each attempt, but if we run out of nodes
to connect to, future connection attempts will fail unless we set this
number properly.

Change-Id: I20125aeda81f5b468e580ef9034a422347f52545