domainwidedelegation.comStart free

Use cases → Documents and Drive

Bulk restore deleted Drive files with domain delegation

Recover batches of deleted files from user Drives or shared drives using delegated access, avoiding tedious manual restores and inconsistent outcomes.

Who it is forAdmins and delegated automation teams handling user or shared drive data loss incidents.
APIsDrive API, Admin SDK
Typical scopesdrive, admin.directory.user.readonly

The problem

When users delete files—accidentally or maliciously—restoring them one-by-one is slow and error-prone, especially across many accounts or shared drives. The Drive trash UI is not designed for bulk recovery, and the 30-day retention window adds urgency.

How it works

  1. Enumerate affected users or drives using Admin SDK.
  2. For each, impersonate the user or shared drive context via domain-wide delegation.
  3. List trashed files with the Drive API, filtering by deletion time or parent folder.
  4. Restore files by updating their 'trashed' property to false.
  5. Log each recovery action for auditing and track which restores failed.

What changes

Deleted files are recovered in volume without user intervention, and the process is auditable and repeatable across the organisation.

The trap in this one. Drive API 'list' results are eventually consistent—recently deleted files may not immediately appear, leading to missed restores if you run too soon after deletion. In addition, restoring a file whose parent folder is still in the trash will succeed but leave the file 'orphaned', invisible to users unless explicitly re-parented. These cases are silent: the API returns success, but the file remains effectively lost.

Watch it explained

“How to archive Google Workspace user to a Drive and Delete without downloading data to a computer.” — Riyas Rawther on YouTube. Third-party video, included because it covers this ground well. We are not affiliated with the channel.

Questions people ask

Can I restore files for suspended or deleted users?

You can restore files for suspended users, but for deleted users, ownership transfer or restoration must occur before account deletion. Once purged, recovery is not possible through the API.

How do I locate orphaned files after bulk restore?

Query for files with no parents after restore, then move them to a known folder. The API does not notify you of orphaning automatically.

Want this built?

This is a pattern we run in production. We will set up the delegation and build this on top of it — $500 per hour, most of it working the same day.

Talk to us Or read the setup guide

Related use cases

Rotate Drive access for external collaborators via automation

Regularly expire and re-grant Drive file access for external users without manual intervention or missed revocations.

Enforce Drive storage quotas on a schedule

Identify and act on users who exceed Drive storage limits by scanning usage periodically and triggering clean-up or escalation.

Migrate Drive data between teams with delegated access

Move shared Drive content for a whole team between organisational units or domains, preserving permissions and structure with a delegated service account.