Sugar backup restore fixes

See commits.