Buzz API

Restoring items with the API -- any hidden gotchas?

Follow
Matthew Marichiba

Are there are any hidden gotchas around restoring users, domains, courses, or enrollments, such as deleted data or broken relationships? I have been writing a tool to undelete accidentally-deleted domains, courses, and users. After restoring a course or a user, we've found that any enrollments related to the course/user have also been deleted. So to restore a deleted user or course to its pre-deleted state, you need to restore the entity's enrollments as well. That seems to do the trick, from what I can tell. (For example, all syllabus items seem to be correctly connected to the undeleted course, and past grades are still there for the restored user's enrollment.) Is there any other nuance that we need to take into account?

For the viewers following along at home, the following pattern is super useful for this find-and-restore process. I'm showing an example for user, but you can exchange user for course, domain, enrollment, etc. 

  • Find deleted entity: cmd=listusers&show=deleted&domain=0&text=john&query=/modifieddate>2016-09-20
  • Restore entity: cmd=restoreuser&userid=123456789

The exact query parameters vary from entity to entity, but the format is basically the same.

 

Comments (6)

Sort by
Darren Severino

I'm curious about this as well. I've never had an issue with it and I've been using it for several years. Also, the commands are considered "obsolete", but if you need to restore a lot of items there are plural versions of all of the restore commands that take a post. The only thing I can really think of is, if you delete a user or domain and create a new one with a conflicting userspace or username respectively, the deleted one will be changed to a guid. Of course, you can change it back after you restore it as long as you get rid of the conflict.

0 Comment actions Permalink
Brad Marshall
  • Agilix team member

Good job, Matthew.

You have found the nuances. When restoring courses and users, you must also restore the associated and desired enrollments. No data is lost nor are relationships broken. 

As you have noted, this does not occur with deleting a domain. You do not need to restore courses/users/enrollments when restoring a domain. 

0 Comment actions Permalink
Brad Marshall
  • Agilix team member

Darren is right, too. If there is a conflicting username or userspace when you restore, we give it a GUID which can then be changed. 

While the obsolete commands do still work, I would recommend issuing a batch request for restoring an entity. For example, the obsolete RestoreUsers command allowed you to restore multiple users at once. While the new RestoreUser command does not do this natively, you can still accomplish it with a batch request (see Command Usage: Issuing Batch Commands). For restoring multiple users, it would look like this.

<batch>
  <request cmd="restoreuser" userid="id" />
  <request cmd="restoreuser" userid="id" />
  <request cmd="restoreuser" userid="id" />
</batch>

I hope this helps!

 

0 Comment actions Permalink
Darren Severino

Doh! I always forget about batch requests! I never use them. I have enough issues with DLAP commands timing out as it is!!

Are there any caveats to changing a domain's userspace? I know it's not documented but I've done it before with no apparent issue. I don't usually do it with "production" domains since it's not documented though.

0 Comment actions Permalink
Brad Marshall
  • Agilix team member

It will fail if you try to update it to a userspace that already exists. As long as all of your custom tools use variables to point to the userspace and is not hardcoded, then it should not be a problem.

0 Comment actions Permalink
Matthew Marichiba

Thanks, guys. Very helpful and timely. I had seen GUIDs getting written into certain fields on old deleted items, but I couldn't quite explain that quirk. 

0 Comment actions Permalink
Please sign in to leave a comment.