Transfer of Google Drive

2,290 views
Skip to first unread message

Mark Harman (ICT Support Engineer)

unread,
Nov 12, 2021, 9:56:51 AM11/12/21
to GAM for Google Workspace
Hi 

In our organization when a person leaves we transfer the ownership of the google drive to the manager. Up until last week, we were using:

gam create datatransfer <source email>   gdrive <destination email>     privacy_level shared,private

This unfortunately stopped working. As a replacement command, we tested:

gam user <source email> transfer drive <destination email>  
However, upon running this command it found 3000+ orphaned files and began to transfer them.   

I am just looking for some advice as to why the first command stopped working and why the second command began to transfer seemingly unrelated orphaned documents. Any help would be greatly appreciated. 

- Mark 

William Yox

unread,
Nov 12, 2021, 11:09:11 AM11/12/21
to GAM for Google Workspace
Hey Mark,

I'm not sure why the first command stopped working, though if it wasn't clear for you already - 

gam create data transfer  is syntax for GAM whereas  gam user <source email> transfer drive <destination email> is the syntax for GAMADV-XTD3. Both should work in XTD3 though.

I tested on my local machine and on a cloud shell, both commands work for me in GAMADV-XTD3 6.10.00. What error are you getting?
Regarding the orphaned documents: As I understand it, orphaned items are those without parents and are therefore owned by the user, but unorganized. Thus they exist, and are owned, and I think they would be part of a data transfer. I may be wrong, but it makes sense to me that they would be transferred.

Without looking at the code, its possible that the two commands are performing similar, but not exactly the same functions. 

Mark Harman (ICT Support Engineer)

unread,
Nov 12, 2021, 11:16:24 AM11/12/21
to GAM for Google Workspace
Thank you for your reply! 

With the first command, I am not getting any errors which is the frustrating part. The command says it's successful and when you run a follow-up command to check on the transfer. it states that the command is successful. But nothing actually happens.  

So with orphaned items, they would have been owned by the source email account? Or would it pick up any unowned documents at the time of transfer? 

Thank you for all your help 
Mark 



William Yox

unread,
Nov 12, 2021, 11:27:43 AM11/12/21
to GAM for Google Workspace
You are very welcome.

When you run gam create datatransfer you should get some feedback that looks like this:

Transfer Request Created
  Transfer ID: <UID of transfer object>
  Service: Drive and Docs
  From: <sourceuser@yourdomain>
  To: <targetuser@youdomain>

If the command completed successfully, you should see this. You can validate the status of your transfer:

gam show datatransfers
gam print datatransfers todrive (if you want a gsheet)

At the very least, you should be getting some feedback in the terminal after you've entered the command.

It is my understanding, which may not be entirely accurate, that 'orphaned' in this case means items owned by a specific user, who are no longer organized in a way that the user could discover them unless by searchind this in Drive: is:unorganized owner:me

Mark Harman (ICT Support Engineer)

unread,
Nov 15, 2021, 5:53:38 AM11/15/21
to GAM for Google Workspace
That is exactly what it shows, and when we run that command to show the status we get: 

Overall Transfer Status: completed
Application: Drive and Docs
Status: completed

But then the new user doesn't get the documents and within google admin, it still shows documents in the original user's account 

Sorry for the delay in replying. Thank you for all your help. 

Brian Kim

unread,
Nov 15, 2021, 7:42:59 AM11/15/21
to GAM for Google Workspace
I wrote a little about it last year and submitted a feature request to Google for Data Transfer API. Because of changes to Drive API, orphaned files are effectively unmanageable as it stands today, unless you query parents for each of the orphaned files and replace them with shortcuts.

William Yox

unread,
Nov 15, 2021, 10:15:51 AM11/15/21
to GAM for Google Workspace
No worries about the reply. We all have things to do!

That is quite odd behavior. Are you able to modify the ACLs of items individually? Have you tried ruling out your local configuration by running from somewhere else, like cloud shell? 

William Yox

unread,
Nov 15, 2021, 10:16:47 AM11/15/21
to GAM for Google Workspace
Whoa this is interesting, not sure how I missed this. I'll give it a read thanks.

Iain Macleod

unread,
Nov 15, 2021, 12:49:21 PM11/15/21
to GAM for Google Workspace
William,

I run the following command before doing a data transfer. It gathers all the users orphans and puts them in a folder titled "Orphans - *username*" in their root. 

gam user <source email> collect orphans targetuserfoldername "Orphans - #user#" useshortcuts true

Donald Boody

unread,
Jan 12, 2022, 12:05:28 PM1/12/22
to GAM for Google Workspace
Iain, is that a standard gam command or an adv gam command

If standard, I guess you're suggesting the script go something like as follows:

gam user $user collect orphans  targetuserfoldername "Orphans - $user" useshortcuts true
$folder = gam user $user show fileinfo name "Orphans - $user" #make sure the folder is created
if($null -ne $folder) {
    gam create datatransfer  $user  gdrive  $destination  privacy_level shared,private
} else {
           $No_Such_User_Error = New-Object System.FormatException "No such folder $folder for $user. Please check for typos."
           Throw $No_Such_User_Error
}

Does that seem correct?

Iain Macleod

unread,
Jan 12, 2022, 12:17:12 PM1/12/22
to google-ap...@googlegroups.com
It is an Advanced gam Command. One you run it it will go through and gather the files one by one (it can take a while on larger accounts). Once that is done I run the "gam create datatransfer  user  gdrive  destination  privacy_level shared,private" part. I don't have a script to automate it.

--
You received this message because you are subscribed to a topic in the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/Tz3L-1vJm08/unsubscribe.
To unsubscribe from this group and all its topics, 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/09b5750d-d224-4726-8d83-dde0a9ccddc3n%40googlegroups.com.



Notice to recipient: This e-mail is only meant for the intended recipient of the transmission, and may be a confidential communication or a communication privileged by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of this e-mail is strictly prohibited. Please notify us immediately of the error by return e-mail and please delete this message from your system. Thank you in advance for your cooperation.

DJNinNZ

unread,
Dec 21, 2022, 10:01:36 PM12/21/22
to GAM for Google Workspace
Hi Iain,
can I ask a question, with the useshortcuts true does n't this just gather/create shortcuts for the files? And does the subsequent data transfer just transfer ownership of the shortcut or does it follow the shortcut and the nalso change ownership of the file?

Regards
Duncan

Brian Kim

unread,
Dec 22, 2022, 8:28:00 AM12/22/22
to GAM for Google Workspace
I thought I saw somewhere that Google fixed the issue with data transfer API that it would include transferring ownership of orphaned files.


Since collecting orphans creates shortcuts to orphaned files, I would imagine files themselves don't transfer ownership 

I would do gam user $oldowner print filelist fullpath and check to see if there are any remaining files and use drive API to change ownership of any remaining files or folders. 

Reply all
Reply to author
Forward
0 new messages