How to recursively transfer file ownership?

283 views
Skip to first unread message

David Walton

unread,
Oct 19, 2022, 12:49:31 PM10/19/22
to GAM for Google Workspace
We are trying to recursively transfer large folders of files from one user to another, but it seems as if there's no way to do this natively in Google (which is astonishing — Am I missing something?). Note that we are not trying to transfer the entire contents of the Drive from one another to another. We're trying to transfer specific directories with upwards of a terabyte of data each.


It claims to do precisely what we want, but the script seems a bit out of date and I'm persistently running into errors.

I know that I could get around this by transferring data from one user's account, into a Shared Drive, and then into another user's account, but that's a manual process with it's own issues.

Is there a way using GAM or natively in Google to selectively transfer ownership of a folder structure from one user's Google Drive to another's?

Thanks!

David Walton

unread,
Oct 19, 2022, 1:09:32 PM10/19/22
to GAM for Google Workspace
Ah, I was just looking again and I think I must have just missed it, here.

Transfer Files from Folder

Create a Google Sheet of the IDs of the files and folders to copy, from a specific folder. The showownedby me will only list the files the Original Owner owns. Then either transfer ownership or copy to a new folder

gam user <Original Owner Email> print filelist select ID <Folder-To-Copy-ID> showownedby me fields id todrive

Transfer the Ownership

gam csv gsheet <User Email Address> <gSheet DriveFileID> <gSheet Name> gam user ~Owner add drivefileacl ~id user <New Owner Email> role owner

Copy to New Folder

gam csv gsheet <User Email Address> <gSheet DriveFileID> <gSheet Name> gam user ~Owner copy drivefile ~id parentid <New Folder ID>


Will this maintain folder/file structure? Is this the best way to accomplish what we're trying to do?

Jay Lee

unread,
Oct 19, 2022, 1:11:54 PM10/19/22
to google-ap...@googlegroups.com
My advice would be to fix whatever process you have in place that is leaving these users on hold so you can use data transfer commands instead of using this workaround.

Jay

--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/dc0ea24a-65a9-47f7-93cb-ca174c34d727n%40googlegroups.com.

David Walton

unread,
Oct 19, 2022, 1:40:47 PM10/19/22
to google-ap...@googlegroups.com
Hi Jay,

I'm not entirely sure what you're referring to.

For context, here's what we're ultimately trying to do: We have a small number of users with several terabytes of data that is worth maintaining, but too expensive to keep in Google given the recent storage changes. So we are migrating certain accounts with massive amounts of archival data from Google Drive to Microsoft 365 using Microsoft's Migration Manager

Microsoft requires accounts with more than 1 TB of data to be split into separate accounts with less than 1 TB each: https://learn.microsoft.com/en-us/sharepointmigration/mm-google-step2-scan-assess?source=recommendations. Most of the accounts that we're talking about have between 1 and 4 TB, so this doesn't seem like it should be a monumental task, except that Google doesn't make it easy to transfer file ownership (a step that MIcrosoft conveniently omits).

So that's what we're trying to do: Migrate archival data from Google to MIcrosoft, which requires that the data to be split between service accounts with a maximum of 1 TB of data each. Right now we're just doing this as a test to see if it's a viable business process for migrating some of the data. The answer might be, "No, this is not a viable solution, given how difficult Google makes it to transfer ownership of data."

Best,



--

David Walton

Information Security Analyst

Jay Lee

unread,
Oct 19, 2022, 2:03:30 PM10/19/22
to google-ap...@googlegroups.com
got it, rather than transferring the ownership within Google I'd suggest just using Takeout to export the data and then migrate from there:


David Walton

unread,
Oct 19, 2022, 2:49:40 PM10/19/22
to google-ap...@googlegroups.com
The primary benefits of the migration tool are to maintain metadata and folder structure. If the migration tool doesn't work well, we'll very likely have to use something like Takeout (though from personal experience Takeout doesn't work well when handling large data archives).

Based on your response, should I assume there isn't a good way to recursively transfer file ownership? Is there not a way to do this via GAM, or another tool?

Bob Merry

unread,
Oct 19, 2022, 3:02:58 PM10/19/22
to google-ap...@googlegroups.com
This is how I have always done it, not sure if there is a better way or not:
**Requires advanced gam**
Build the list of files that you want transferred, get the root folder ID from the user or from a dump of their files. 
gam user us...@domain.com print filelist select <root folder id> fields id,name,webviewlink,owners.emailaddress,modifiedtime >gnfiles.csv
Transfer ownership
gam csv gnfiles.csv gam user ~Owner add drivefileacl ~id user transfe...@domain.com role owner
Then if you want to remove access from the original owner in the gnfiles.csv file find and replace us...@domain.com to transfe...@domain.com
gam csv gnfiles.csv gam user ~Owner delete drivefileacl ~id us...@domain.com

Bob

Jay Lee

unread,
Oct 19, 2022, 3:37:29 PM10/19/22
to google-ap...@googlegroups.com
Sorry, I'm still not totally understanding the use case here, rather than transferring the files and then migrating them I'd aim for a more direct approach to just directly migrate the fles to their new location. But to answer your question, yes you can do a data transfer from one user to another:


Jay Lee


Bob Merry

unread,
Oct 19, 2022, 3:46:36 PM10/19/22
to google-ap...@googlegroups.com
Data transfers transfer all files if you only want to transfer a particular folder and all of its children you cannot use a data transfer unless there's a special way to do it that I've never seen. 

My use cases for this are project folders that are too big for shared drives that get transferred from one manager to another and when I a termed user's files are transferred to a manager and then a new manager is brought on in that folder needs to be transferred to the new manager. 

Ross Scroggs

unread,
Oct 19, 2022, 3:54:33 PM10/19/22
to google-ap...@googlegroups.com

David Walton

unread,
Oct 19, 2022, 6:24:44 PM10/19/22
to google-ap...@googlegroups.com
Ross Scroggs to the rescue once again.

Thanks, Ross. This is great. I suspected you had something written up for accomplishing this, but only looked through your scripts and didn't think to look through your Wiki.

I tried this with a test folder and it worked flawlessly. It does take a bit of time, so I'll test it with a ~600gb folder overnight and see how it goes.

Noah Barker

unread,
Oct 20, 2022, 2:11:33 PM10/20/22
to GAM for Google Workspace

How did your 600gb transfer go? I am needing to transfer a couple folders totaling ~60gb and even the preview is taking 20-30 minutes.   
  
Side note, when running this command are all of the operations staged or will my device need to be powered on and connected to the internet from when I push the command out until the last file is transfer?

David Walton

unread,
Oct 20, 2022, 2:20:03 PM10/20/22
to google-ap...@googlegroups.com
Noah,

I set it to go overnight and it was successful, but I must have set my variables incorrectly because a number of items were still owned by the source account (alternatively, it's possible it didn't completely properly).

I will be testing again soon.

As a note, I just saw today that Google has once again improved migrating folders to Shared Drives. While it still requires an admin account, it errors out much less, so using Shared Drives as an intermediary for large quantities of data might be the fastest solution.

CONFIDENTIALITY NOTICE
 
This message and attachments included are intended only for the addressee (s). The information contained in this message is confidential and may constitute proprietary or non-public information under international, federal, and/or state laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee(s), please promptly delete this message and notify the sender of the delivery error by e-mail.

--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

Nathan Kuhl

unread,
Oct 20, 2022, 3:44:59 PM10/20/22
to GAM for Google Workspace
Hi David, which command/method did you go with? I'm trying to do something similar as well. I have one folder with hundreds of individual files and folders that need to have their ownership transferred.

Ross Scroggs

unread,
Oct 20, 2022, 5:36:50 PM10/20/22
to google-ap...@googlegroups.com
Nathan,

Send me a Meet/Zoom invitation and I'll help.

Ross



--

David Walton

unread,
Oct 21, 2022, 11:32:02 AM10/21/22
to google-ap...@googlegroups.com
Hi Nathan,

I used Ross' method above and I used a different option of transferring ownership via Shared Drives. Here's my takeaway:
  • Using GAM: This provides much more granular control of precisely how you want Google to handle each file, and you could do it with a batch of users at a time—but the entire process takes much longer due to all the individual API calls it needs to make.
  • Using Shared Drives: This is the fastest option, but provides the least control over how to handle files, and as we all know transferring folders to Shared Drives is a bit buggy and has some gotchas.
For simple data sets, I would use Shared Drives. You need to make sure the source account has the admin role of moving folders into Shared Drives. Simply create a Shared Drive and add both the source and target account as members, then move the data from the source account, into the Shared Drive, and then into the target account. This process will throw up errors if you have a large number of files or folders owned by outside users or other users who aren't members of the Shared Drive. The data I was working with was ~600GB all uploaded by a single user, so I didn't have to worry about unexpected file permissions.

For complex data sets, I would definitely recommend Ross' GAM documentation: 
https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Drive-Transfer#gam-data-transfers



Kim Nilsson

unread,
Oct 24, 2022, 2:29:49 AM10/24/22
to GAM for Google Workspace
Ross, in what way is a GAM Data Transfer, selecting a start folder, different from using GAM Claim on a folder?

/Kim

 

Temple Rodgers

unread,
Oct 24, 2022, 5:47:26 AM10/24/22
to GAM for Google Workspace
Late entering this discussion ... one tool that isn't GAM is Workspace Migrate - it will transfer selected folders within Google Workspace either in the same account or between different accounts and between my/shared drives<>my/shared drives. It won't work at an individual file level though. It'll need a minimum of 4 Windows servers but it works very well and is completely auditable.
Temple

My Routes

unread,
Oct 27, 2022, 2:49:24 PM10/27/22
to GAM for Google Workspace
Is it possible with GAM to recursively transfer file ownership across domains/Google Workspaces as implemented in Transfer Files Ownership (webapp)?

Ross Scroggs

unread,
Oct 27, 2022, 3:05:04 PM10/27/22
to google-ap...@googlegroups.com
No.

Ross

--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.


--

Yanuar Handoyo

unread,
Nov 2, 2022, 3:08:43 AM11/2/22
to google-ap...@googlegroups.com
devops@docker:~/employee$ gam user userA add drivefileacl 1KpukNob4LEpmKX-hb5E-wSCIWWZK-z6b user userB role owner
User: userA, Add 1 Drive File/Folder ACL
  User: userA, Drive File/Folder ID: 1KpukNob4LEpmKX-hb5E-wSCIWWZK-z6b, Permission ID: userB, Add Failed: Sorry, you do not have permission to share."

what's the meaning ? Add Failed: Sorry, you do not have permission to share."



--
Best Regards,
Yan
Sent via Gmail Google Workspace



Pemberitahuan Kerahasiaan: Informasi yang terkandung dalam email elektronik ini (dan setiap lampirannya) bersifat rahasia dan/atau mungkin juga memiliki hak istimewa secara hukum, dimaksudkan hanya untuk digunakan oleh individu-individu atau entitas yang dituju. Jika anda bukan penerima yang dituju, anda dengan ini diberitahukan bahwa anda dilarang keras untuk menyalin, menggunakan, mendistribusikan kembali atau mengungkapkan isinya kepada pihak lain. Segera beritahukan pengirim dengan mereply email untuk menginformasikan bahwa ada kesalahan dan menghapus email asli ini dan semua salinan yang ada dari sistem Anda.

Confidentiality Notice: The information contained in this electronic e-mail (and any attachments) is confidential and /or may also be legally privileged, intended solely for the use of the individuals or entities to whom they are addressed. If you are not the intended recipient, you are hereby notified that you are strictly prohibited to copy, use, redistributed or disclosed its content to any other person. Please immediately notify the sender by return e-mail that you have received the message in error and delete the original message and all copies from your system

Kim Nilsson

unread,
Nov 2, 2022, 3:56:09 AM11/2/22
to Google Apps Manager
It should mean that userA doesn't have the necessary rights to change the access.

/Kim 

David Amos

unread,
Nov 26, 2022, 8:12:13 AM11/26/22
to GAM for Google Workspace
The only way round this is, in the new domain (domain b), create a shared drive and give the user form domain a access as a manager to the shared drive then run under GAM (in domain a)

gam user <email address domain a> move drivefile <file/folder ID> parentid <destination folder id>

Kind Regards

Dave

Ajo Jose

unread,
Nov 26, 2022, 8:43:55 AM11/26/22
to GAM for Google Workspace
Hi,

If the file is already in one user drive why can't we just do this?
(I am not sure if this is what your requirement is)

Share a file.png
Reply all
Reply to author
Forward
0 new messages