Fix 'Undefined variable' bug in backup code

This was introduced by Sam Marshall's backup/restore improvements backport (sammarshallou@6f1f724) so will need to be reverted too if Sam's commit is reverted.