Move folder from one Shared Drive to another SD in another domain

2,088 views
Skip to first unread message

Kim Nilsson

unread,
Sep 27, 2021, 9:19:26 AM9/27/21
to GAM for Google Workspace
This is possible in the Drive interface, so I'm hoping it is possible with gam too.

I've made a couple of tries, but so far it's failing.
I also tried copying, and that failed too.

I know gam doesn't really like working across two domains at once, but since this works in the Drive interface, I'm hoping it's just me doing something wrong.

Now, these are the requirements.
1. In Drive Sharing settings in your root OU you must allow Anyone to move files/folders outside of a Shared Drive (#5). The root OU holds the settings for all SDs.

2. The external user (kim) must be a Manager of both the internal (source) SD and the external (destination) SD.

3. The external user (kim) must be allowed to move folders to SDs in the external (destination) domain (which for kim is his domain). That's accomplished by assigning a delegated admin role with that right to kim in the external domain.

I repeat - this works in the Drive interface.
It works both by moving the SD-folder to an external user's MyDrive, and into an external SD. I've verified this several times, so please don't argue that it doesn't.

My question is, can gam do it?

When trying this with gamadv-xtd3 I get a number of different error messages.

User with Manager role in both internal and internal Shared Drive: kim
Now, all GAM actions is done as the admin of the domain where kim exists.
So when I write 0ABC123externalSD it's actually the SDid of the source, which is external to the kim-domain.

1234abcexternalfolder is the folder I wish to move, currently belonging to the source.
0XYZinternalSD is the destination-SD on the kim-domain to where I wish to move the folder.

$ gam user kim move drivefile teamdriveid 0ABC123externalSD teamdriveparentid 1234abcexternalfolder teamdriveparentid 0XYZinternalSD

User: kim@domain, Move 1 Drive File/Folder
ERROR: 403: fileNeverWritable - This file is never writable.

$ gam user kim copy drivefile teamdriveid 0ABC123externalSD 1234abcexternalfolder teamdriveparentid 0XYZinternalSD

Command: /home/kim/gamadv-xtd3/gam user kim copy drivefile teamdriveid 0ABC123externalSD >>>1234abcexternalfolder<<< teamdriveparentid 0XYZinternalSD
ERROR: Invalid argument
Help: Syntax in file /home/kim/gamadv-xtd3/GamCommands.txt
Help: Documentation is at https://github.com/taers232c/GAMADV-XTD3/wiki

$ gam user kim copy drivefile teamdriveid 0ABC123externalSD select 41234abcexternalfolder teamdriveparentid 0XYZinternalSD

Command: /home/kim/gamadv-xtd3/gam user kim copy drivefile teamdriveid 0ABC123externalSD >>>select<<< 41234abcexternalfolder teamdriveparentid 0XYZinternalSD
ERROR: Invalid argument
Help: Syntax in file /home/kim/gamadv-xtd3/GamCommands.txt
Help: Documentation is at https://github.com/taers232c/GAMADV-XTD3/wiki

$ gam user kim copy drivefile teamdriveid 41234abcexternalfolder teamdriveparentid 0XYZinternalSD

User: kim@domain, Copy 1 Drive File/Folder
  User: kim@domain, Drive File/Folder ID: 41234abcexternalfolder, Copy Failed: Does not exist

Kim Nilsson

unread,
Sep 27, 2021, 2:58:51 PM9/27/21
to GAM for Google Workspace
Ok, Ross helped me find my typos. :-)

First, my three requirements are still 100% necessary.
(Rephrased a little to indicate that gam is doing this magic in/from the kim (the destination) domain.)

1. In Drive Sharing settings of the source domain in the root OU you must allow Anyone to move files/folders outside of a Shared Drive (#5). That's because the root OU holds the settings for all SDs.

2. The destination user (kim) must be a Manager of both the source (external) SD and the destination SD.

3. The destination user (kim) must be allowed to move folders to SDs in the destination domain (which for kim is his domain). That's accomplished by assigning a delegated admin role with that right to kim in the destination domain.

Now, this is how to copy a folder from one Shared Drive to another in a completely separate Workspace domain/account.
Exactly like you would to it with a folder inside your own domain. Without typos, and with recursive. :-)

$ gam user kim copy drivefile 1234abcexternalfolder teamdriveparentid 0AFOx2exBkqqAUk9PVA recursive
User: kim@domain, Copy 1 Drive File/Folder
  User: kim@domain, Drive Folder: Move this folder to external domain, Copied to: Move this folder to external domain, Drive Folder ID: 1234NewInternalFolder
    User: kim@domain, Drive File: Just a simple Doc inside a folder inside a Shared Drive, Copied to: Just a simple Doc inside a folder inside a Shared Drive, Drive File ID: 1234NewDocFileId

Exact same thing, but moving the folder and it's content instead.

$ gam user kim move drivefile 1234abcexternalfolder teamdriveparentid 0XYZinternalSD
User: kim@domain, Move 1 Drive File/Folder
  User: kim@domain, Drive Folder: Move this folder to external domain, Moved to: Move this folder to external domain, Drive Folder ID: 0XYZinternalSD

But as Ross cleverly explained, a move is actually only a change of parent, so why not just do that instead?

$ gam user kim update drivefile 1234abcexternalfolder teamdriveparentid 0XYZinternalSD
User: kim@domain, Update 1 Drive File/Folder
  User: kim@domain, Drive Folder: Move this folder to external domain, Updated

Seems to be a much faster, cleaner process.

So, yes, it is very much possible to let gam move a file/folder from one domain's Shared Drive to another domain's Shared Drive.

Just avoid typos and you're good to go! :-)

Brian Kim

unread,
Sep 27, 2021, 7:52:29 PM9/27/21
to GAM for Google Workspace
Thanks for sharing! I knew it should be possible, but didn't have a chance to test it out. So If I list all the items in the root of the Shared Drive, update their parents to the new teamdriveparentid, I will be able to move all items in the Shared Drive from source to destination, right? (Similar to how you can list items in the root of shared drive and delete in cases where you has users that were involved in Shared Drive scam)

Kim Nilsson

unread,
Sep 28, 2021, 6:28:32 AM9/28/21
to Google Apps Manager
Yup, should work just fine. 

Dametrius King

unread,
Oct 12, 2021, 1:46:27 PM10/12/21
to google-ap...@googlegroups.com
Sorry to open this old thread again but I can't get this command to work when moving folders from a MyDrive to a Shared Drive. Here's the error I receive.

$ gam oauthuser update drivefile 1w1i07tmU8V5ypOePY8QdwdzYDyHTQqI_ teamdriveparentid 0AL_JOEiGx9zdUk9PVA

User: dame...@deployment.cloudbakers.com, Update 1 Drive File/Folder
  User: dame...@deployment.cloudbakers.com, Drive File/Folder ID: 1w1i07tmU8V5ypOePY8QdwdzYDyHTQqI_, Update Failed: Moving folders into shared drives is not supported.



Dametrius King | Deployment Engineer
Office: (312) 380-6838 | Direct: (708) 669-9342
Latest News:


On Tue, Sep 28, 2021 at 5:28 AM Kim Nilsson <there.is.no...@gmail.com> wrote:
Yup, should work just fine. 

--
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/CAGPzzFsCtrJ3eid7KhXJ%2Bv6MznZXYpvR2m5UOfjtUXaZmwTVGQ%40mail.gmail.com.

Kim Nilsson

unread,
Oct 12, 2021, 2:03:22 PM10/12/21
to Google Apps Manager
Hi, Dametrius!

Your user needs to be allowed to move folders to a Shared Drive.
This means the user that is supposed to move the folder to a Shared Drive must be the Workspace user.
Either it needs to be a superadmin or a delegated admin with the right to move folders to a shared Drive.

Just like I stated in my three rules.

/Kim
--
There is No Substitute!

Harry Baker

unread,
Mar 10, 2023, 11:24:37 AM3/10/23
to GAM for Google Workspace
Good Morning,

First off, would like to say that this conversation, github, etc. has been extremely useful for our use case. As some background, my organization is migrating its legacy google drive to a new google drive (my company was purchased and we are migrating all of our drive files). We are looking to move from a shared drive in our legacy domain to a share drive in our new domain using GAM. We have been testing and are running into a few issues we hope that you all may be able to help out with. 

Our super admin is currently running this code, and we believe we have set up the 3 requirements as listed above. Note we are taking a slightly different approach than some of the above comments and just trying to move everything within a share drive. Here is the code we just ran and the corresponding issue: 

From GitHub: gam user us...@domain.com copy drivefile teamdriveid 0AC_1AB teamdriveparentid 0AE_9ZX mergewithparent recursive

Our Code: gam user managerofs...@domain.com copy drivefile teamdriveid sourcesharedriveid teamdriveparentid targetsharedriveid mergewithparent recursive

Error: 
User:  managerofs...@domain.com   , Copy 1 Drive File/Folder
  User:  managerofs...@domain.com   , Drive Folder:  sourcesharedriveid , Merge contents with Drive Folder:  targetsharedriveid
Traceback (most recent call last):
  File "__init__.py", line 67759, in ProcessGAMCommand
  File "__init__.py", line 52479, in copyDriveFile
  File "__init__.py", line 52227, in _recursiveFolderCopy
  File "__init__.py", line 45796, in _getEntityMimeType
KeyError: 'mimeType'

As a note, the content of the folder is 2 sub-folders, some PDFs, JPGs, and Docx file types

Any help would be sincerely appreciated, and I'd be happy to provide more information if needed.

Thanks all!
Harry 

Kim Nilsson

unread,
Mar 10, 2023, 11:43:30 AM3/10/23
to google-ap...@googlegroups.com
Have you verified that you are on the latest version of GAMADV-XTD3?--

Harry Baker

unread,
Mar 10, 2023, 11:44:34 AM3/10/23
to GAM for Google Workspace
Yes, we just updated to the most recent version of GAMADV-XTD3!

We had some previous issues and updated and it seemed to resolve those

Harry

Kim Nilsson

unread,
Mar 10, 2023, 11:48:33 AM3/10/23
to google-ap...@googlegroups.com
Anyway, I thought my idea and instructions was to move and not copy files? Your command uses copy.--

Rance Hall

unread,
Mar 10, 2023, 11:51:20 AM3/10/23
to google-ap...@googlegroups.com

Crossing the domain boundary with GAM is difficult at best.

 

You might want to have a look at rclone which is a much better tool for this.

 

https://rclone.org

 

-- 

Rance Hall

ESU10 Network Services

rance...@esu10.org

308-698-1919

 

 

 

From: 'Harry Baker' via GAM for Google Workspace <google-ap...@googlegroups.com>
Date: Friday, March 10, 2023 at 10:24 AM
To: GAM for Google Workspace <google-ap...@googlegroups.com>
Subject: Re: [GAM] Re: Move folder from one Shared Drive to another SD in another domain

[EXTERNAL EMAIL]

--

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.

Kim Nilsson

unread,
Mar 10, 2023, 12:01:56 PM3/10/23
to google-ap...@googlegroups.com
Rance, it actually works great between Shared Drives.--

Rance Hall

unread,
Mar 10, 2023, 12:04:17 PM3/10/23
to google-ap...@googlegroups.com

Kim that feels like a configuration nightmare, but hey if it works, it works.

 

When we did this for our schools it was rclone all the way.  But haven’t needed to do it in forever.

 

R

 

-- 

Rance Hall

ESU10 Network Services

rance...@esu10.org

308-698-1919

 

 

 

From: google-ap...@googlegroups.com <google-ap...@googlegroups.com> on behalf of Kim Nilsson <there.is.no...@gmail.com>
Date: Friday, March 10, 2023 at 11:02 AM
To: google-ap...@googlegroups.com <google-ap...@googlegroups.com>
Subject: Re: [GAM] Re: Move folder from one Shared Drive to another SD in another domain

[EXTERNAL EMAIL]

Rance, it actually works great between Shared Drives.--

--

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.

Kim Nilsson

unread,
Mar 10, 2023, 12:10:25 PM3/10/23
to google-ap...@googlegroups.com
Supereasy with advanced gam.--

Ross Scroggs

unread,
Mar 10, 2023, 4:22:34 PM3/10/23
to google-ap...@googlegroups.com
Harry,

It's a bug, will fix.

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.


--

Ross Scroggs

unread,
Mar 10, 2023, 5:21:00 PM3/10/23
to google-ap...@googlegroups.com
Bug fixed in 6.50.14

Ross
--

Joshua Feld

unread,
Mar 10, 2023, 5:34:49 PM3/10/23
to GAM for Google Workspace
Thank you Ross!

I thought I was going crazy trying to copy files with 6.50.12 but I was able to get it working downgrading to 6.4X
This message is for the sole use of the intended recipient(s). It may contain confidential information. Any unauthorized review, use, disclosure, or distribution is prohibited. If you are not the intended recipient, please alert the sender by reply email and destroy all copies of the original message, including attached files.

Ross Scroggs

unread,
Mar 10, 2023, 5:36:36 PM3/10/23
to google-ap...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages