Added retry loop to restore script