Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to Team Drives (gdrive) #885

Closed
jwhitelbl opened this issue Nov 15, 2016 · 55 comments
Closed

Access to Team Drives (gdrive) #885

jwhitelbl opened this issue Nov 15, 2016 · 55 comments

Comments

@jwhitelbl
Copy link

jwhitelbl commented Nov 15, 2016

I can't seem to figure out how to access a newly created Team Drive (fairly new feature, detailed briefly here under "Drive for Teams" https://butt.googleblog.com/2016/09/intelligent-tools-built-for-teams.html)

Team drive name is "HPCS" (not listed in lsd output, doesn't seem to be a way to configure it as a distinct config item).

What is your rclone version (eg output from rclone -V)
rclone v1.34

Which OS you are using and how many bits (eg Windows 7, 64 bit)
Linux (debian 8.4 64bit)

Which butt storage system are you using? (eg Google Drive)
Google Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)
rclone lsd gdrive:

A log from the command with the -v flag (eg output from rclone -v copy /tmp remote:tmp)

root@rclone:/root# rclone lsd gdrive-hpcs:
-1 2016-11-09 20:34:32 -1 crypt
-1 2016-10-27 20:01:38 -1 bluearc
-1 2016-06-20 15:27:40 -1 HPCS-Backups
-1 2015-06-03 20:33:49 -1 2015-05
-1 2015-04-28 16:57:34 -1 Lucidchart
-1 2015-03-19 16:06:46 -1 BRC_Storage
2016/11/15 18:26:24
Transferred: 0 Bytes (0 Bytes/s)
Errors: 0
Checks: 0
Transferred: 0
Elapsed time: 900ms
root@rclone:~#

@gustavorochakv
Copy link

The Google Drive API doesn't work with Team Drive. I'm unaware of any public API that can interact with Team Drive.

@davidjgraph
Copy link

I'm told that the API is now enabled for Team Drives, but I've no idea what needs to be done to support it.

@ncw
Copy link
Member

ncw commented Feb 17, 2017

@davidjgraph what happens if you use rclone config with the drive option with a team drive? Does that work now?

@dav1303
Copy link

dav1303 commented Feb 18, 2017

Hi
I have made a test but stills not working. Unfortunatly TD spaces stills not visible
Regards

@pasteof
Copy link

pasteof commented Mar 10, 2017

This would be really nice to have, looking around it looks like the API supports team drives now.
https://developers.google.com/drive/v2/reference/teamdrives

@jahands
Copy link
Contributor

jahands commented Mar 10, 2017

Looks like google.golang.org/api/drive/v2 supports Team Drives now as well.

@ncw ncw added this to the Unplanned / Help Wanted milestone Mar 10, 2017
@ncw
Copy link
Member

ncw commented Mar 10, 2017

Does anyone want to work on this?

I don't have access to a team drive unfortunately...

@jahands
Copy link
Contributor

jahands commented Mar 10, 2017

@ncw Ok so it turns out you don't need to be part of a G Suite Business org to use Team Drives anymore.

If you can send me your Google account email I can invite you to a Team Drive.

@ncw
Copy link
Member

ncw commented Mar 13, 2017

@jahands I've sent you an email with my gmail!

@jahands
Copy link
Contributor

jahands commented Mar 13, 2017

@ncw Thanks! You should now see Team Drives over in drive.google.com

@ncw
Copy link
Member

ncw commented Mar 13, 2017

@jahands thanks for that - it is working fine!

A bit of poking around discovers

  • I'll need to update the drive API package to get access to team drives
  • I'll need to list the team drives to get their ids (which is also the id of their top level folder)
  • once I have their ids then rclone should work as normal (though might need to set some extra flags in the files list method

How do you think this should be used from within rclone?

Using the handy graphic above, rclone uses the contents of "My Drive" above. I could add a flag, say --drive-team-drive NAME which means that it will use the team drive with that name instead.

Or instead of a flag it could be an item in the config that you set the name of the team drive you want to use. I think this might make the most sense - it makes each team drive a different remote which would make it easy to copy between remotes.

Alternatively I could make a kind of virtual file system making a Pseudo Directory "Team Drives" and within that a pesudo directory for each team drive the API lists. That goes against the way the drives are organised in reality (see pic above) which is bound to lead to trouble!

Thoughts?

@ncw ncw modified the milestones: v1.37, Unplanned / Help Wanted Mar 13, 2017
@jahands
Copy link
Contributor

jahands commented Mar 13, 2017 via email

@jahands
Copy link
Contributor

jahands commented Mar 13, 2017

Or instead of a flag it could be an item in the config that you set the name of the team drive you want to use. I think this might make the most sense - it makes each team drive a different remote which would make it easy to copy between remotes.

I like this.

@TripleFrequency
Copy link

In terms of the process involved in adding a Team Drive, I think the best option would be to either offer it as an option within the creation of a gdrive remote, or have a separate remote.

If it is done as a remote:
It could work much like the crypt remote. Basically choose a pre-existing gdrive remote, then list the team drives by name, allowing for selection, as below.

If it is done as an extra step within a gdrive creation:
Before the first prompt, a GET request could be made for a list of team drives. If the list is empty, continue normally. If it isn't empty, then parse the names and offer them in a selection menu. I feel something along the lines of

1> None/Regular Drive
2> $drive2Name
3> $drive3Name
Please enter the id of the team drive you would like to use:

In terms of API implementation, it should be relatively simple:
Based on Google's Documentation, Team Drives interact using the same API Calls as regular files, but they have an extra "teamDriveID", which designates whether to base file locations, ids, etc on those inside a team drive.

Taking a flag with the team drive name could be trickier than you think, as it doesn't appear to be supported in that way from the API.

To get the IDs, then names of the Team Drive, you could, as @ncw suggested, list the team drives. The returned "items" could then be parsed into a name with another request for team drive metadata, which returns a "name" field, among others.

All other modifications of files essentially just need a "teamDriveID" tacked onto it.

Someone with familiarity with RClone's code could do this with relative simplicity.
I lack knowledge of GO or the code base, but might be able to assist in minor ways if needed.

@gustavorochakv
Copy link

I'm not sure how well picking a name from a list would scale for admin users in orgs with a sizeable number of Team Drives (like one drive per department in a large corp or orgs with one Team Drive per project).
Maybe that should be the default route, but also allow one to bypass it and input the team drive name and id directly.

This is an issue the official client also has, by the way, and I know for a fact that Google has received feedback about it (whether they'll ever tackle that is an entirely different question).

@ncw
Copy link
Member

ncw commented Mar 27, 2017

@gustavorochakv good point!

@TripleFrequency
Copy link

Another thing to possibly consider:

If the destination/source is not a team drive, and the owner has read/write access to the team drive, then it should be server-side copy and move.

A small example:
If I have source file A in a team drive, and a destination folder B, between two remotes, then the following should happen:
file A should have a server-side copy made of file A, then the copy should be moved (from the team drive into a private drive) in folder B.

@pasteof
Copy link

pasteof commented Apr 14, 2017 via email

@TripleFrequency
Copy link

Agreed, but on a related note, rclone server-side copy takes some time also.

@pasteof
Copy link

pasteof commented Apr 14, 2017 via email

@TripleFrequency
Copy link

I have noted that appearance of files in a team drive is more of a visibility bug than it not being moved. It takes moments for it to copy, but I have noted that, while my main account couldn't see the file immediately, other accounts in the team drive could. From testing I have found it to take roughly the same time as a copy, if not a slightly longer amount of time.

@pmwoodward3
Copy link

So is there support for team drives? I looked over this thread but didn't really get a clear yes/no/eta.

@jahands
Copy link
Contributor

jahands commented May 23, 2017 via email

@pmwoodward3
Copy link

Shoot, any suggestions on how to backup a team drive locally? Pretty much my boss is wondering how we could get a copy of everything nightly.

@calisro
Copy link
Member

calisro commented Jun 2, 2017

I got this error when I was configuring it:

Log in and authorize rclone for access
Waiting for code...
Got code
2017/06/02 10:45:29 ERROR : Failed to save new token in config file: section 'XXXXXX' not found
Configure this as a team drive?
y) Yes
n) No
y/n> y

Seems to be working. I copied a folder to test things out. and one error was odd. Over and over it tried to copy 0B_raumxsbgcgYk9oOGhSSmZjcjg which I have no idea what that actually is.....

./rclone copy XXXXX:/XXXXX/XXXXX/XXXXX  XXXXX:/XXXXX/XXXXX/XXXXX -vv
2017/06/02 10:50:13 DEBUG : rclone: Version "v1.36-156-ge1f0e0f5-team-driveβ" starting with parameters ["./rclone" "copy" "XXXXXX:/XXXXXX/XXXXX/XXXXX" "XXXXXX:/XXXXX/XXXXX/XXXXX" "-vv"]
2017/06/02 10:50:14 INFO  : Google drive root 'XXXXXX/XXXXX/XXXXX': Modify window is 1ms
...
...
2017/06/02 10:51:11 DEBUG : 01_20170602004337000.MP4: Sending chunk 109051904 length 6653388
2017/06/02 10:51:12 ERROR : 01_20170602004337000.MP4: Failed to copy: googleapi: Error 404: File not found: 0B_raumxsbgcgYk9oOGhSSmZjcjg, notFound
2017/06/02 10:51:12 DEBUG : 01_20170601235309000.MP4: Sending chunk 75497472 length 8388608
2017/06/02 10:51:14 DEBUG : 01_20170601235309000.MP4: Sending chunk 83886080 length 8388608
2017/06/02 10:51:14 INFO  : 
Transferred:   460.333 MBytes (7.542 MBytes/s)
Errors:                 1
Checks:                 0
Transferred:            0
Elapsed time:        1m1s
Transferring:
 *                      01_20170601235309000.MP4: 17% done, 1.814 MBytes/s, ETA: 3m47s
 *                      01_20170602001421000.MP4: 29% done, 2.151 MBytes/s, ETA: 2m43s
 *                      01_20170602002850000.MP4: 25% done, 1.617 MBytes/s, ETA: 3m23s
 *                      01_20170602005739000.MP4: 25% done, 574.274 kBytes/s, ETA: 10s

2017/06/02 10:51:16 DEBUG : 01_20170602002850000.MP4: Sending chunk 109051904 length 8388608
2017/06/02 10:51:17 DEBUG : 01_20170602001421000.MP4: Sending chunk 150994944 length 8388608
2017/06/02 10:51:18 DEBUG : 01_20170601235309000.MP4: Sending chunk 92274688 length 8388608
2017/06/02 10:51:20 INFO  : 01_20170602005739000.MP4: Copied (new)
2017/06/02 10:51:21 DEBUG : 01_20170602001421000.MP4: Sending chunk 159383552 length 8388608
2017/06/02 10:51:23 DEBUG : 01_20170602001421000.MP4: Sending chunk 167772160 length 8388608
2017/06/02 10:51:23 INFO  : 01_20170602005845000.MP4: Copied (new)
2017/06/02 10:51:24 DEBUG : 01_20170602001421000.MP4: Sending chunk 176160768 length 8388608
2017/06/02 10:51:25 INFO  : 01_20170602005933000.MP4: Copied (new)
2017/06/02 10:51:26 DEBUG : 01_20170602001421000.MP4: Sending chunk 184549376 length 8388608
2017/06/02 10:51:27 DEBUG : 01_20170602010017000.MP4: Sending chunk 0 length 8388608
2017/06/02 10:51:27 DEBUG : 01_20170601235309000.MP4: Sending chunk 100663296 length 8388608
2017/06/02 10:51:29 DEBUG : 01_20170602002850000.MP4: Sending chunk 117440512 length 8388608
2017/06/02 10:51:29 DEBUG : 01_20170602010017000.MP4: Sending chunk 8388608 length 8388608
2017/06/02 10:51:31 DEBUG : 01_20170601235309000.MP4: Sending chunk 109051904 length 8388608
2017/06/02 10:51:33 DEBUG : 01_20170602002850000.MP4: Sending chunk 125829120 length 8388608
2017/06/02 10:51:33 DEBUG : 01_20170602010017000.MP4: Sending chunk 16777216 length 8388608
2017/06/02 10:51:34 DEBUG : 01_20170602001421000.MP4: Sending chunk 192937984 length 8388608
2017/06/02 10:51:36 DEBUG : 01_20170602010017000.MP4: Sending chunk 25165824 length 8232141
2017/06/02 10:51:36 DEBUG : 01_20170602002850000.MP4: Sending chunk 134217728 length 8388608
2017/06/02 10:51:36 DEBUG : 01_20170601235309000.MP4: Sending chunk 117440512 length 8388608
2017/06/02 10:51:37 ERROR : 01_20170602010017000.MP4: Failed to copy: googleapi: Error 404: File not found: 0B_raumxsbgcgYk9oOGhSSmZjcjg, notFound
2017/06/02 10:51:38 INFO  : 01_20170602010715000.MP4: Copied (new)
2017/06/02 10:51:39 DEBUG : 01_20170602001421000.MP4: Sending chunk 201326592 length 8388608


I'm having a lot of failures though with that repeated message. Pretty wierd:


Transferred:   8.482 GBytes (8.034 MBytes/s)
Errors:                23
Checks:                 0
Transferred:            8
Elapsed time:       18m1s
2017/06/02 11:08:06 DEBUG : 01_20170602041239000.MP4: Sending chunk 520093696 length 5736165
2017/06/02 11:08:06 DEBUG : 01_20170602035337000.MP4: Sending chunk 260046848 length 8388608
2017/06/02 11:08:07 DEBUG : 01_20170602033554000.MP4: Sending chunk 486539264 length 8388608
2017/06/02 11:08:08 ERROR : 01_20170602041239000.MP4: Failed to copy: googleapi: Error 404: File not found: 0B_raumxsbgcgYk9oOGhSSmZjcjg, notFound
2017/06/02 11:08:08 DEBUG : robgs: Saved new token in config file
2017/06/02 11:08:09 DEBUG : 01_20170602040217000.MP4: Sending chunk 243269632 length 8388608
2017/06/02 11:08:10 DEBUG : 01_20170602035337000.MP4: Sending chunk 268435456 length 8388608
2017/06/02 11:08:11 DEBUG : 01_20170602042157000.MP4: Sending chunk 0 length 8388608
2017/06/02 11:08:12 DEBUG : 01_20170602042157000.MP4: Sending chunk 8388608 length 8388608
2017/06/02 11:08:14 DEBUG : 01_20170602033554000.MP4: Sending chunk 494927872 length 8388608
2017/06/02 11:08:14 DEBUG : 01_20170602035337000.MP4: Sending chunk 276824064 length 8388608
2017/06/02 11:08:14 INFO  : 
Transferred:   8.482 GBytes (8.034 MBytes/s)
Errors:                23
Checks:                 0
Transferred:            8
Elapsed time:       18m1s
Transferring:
 *                      01_20170602033554000.MP4: 96% done, 1.558 MBytes/s, ETA: 11s
 *                      01_20170602035337000.MP4: 54% done, 1.592 MBytes/s, ETA: 2m24s
 *                      01_20170602040217000.MP4: 49% done, 1.651 MBytes/s, ETA: 2m33s
 *                      01_20170602042157000.MP4:  3% done, 3.872 MBytes/s, ETA: 2m4s

2017/06/02 11:08:15 DEBUG : 01_20170602040217000.MP4: Sending chunk 251658240 length 8388608
2017/06/02 11:08:16 DEBUG : 01_20170602033554000.MP4: Sending chunk 503316480 length 8388608
2017/06/02 11:08:18 DEBUG : 01_20170602035337000.MP4: Sending chunk 285212672 length 8388608
2017/06/02 11:08:18 DEBUG : 01_20170602033554000.MP4: Sending chunk 511705088 length 8388608
2017/06/02 11:08:18 DEBUG : 01_20170602042157000.MP4: Sending chunk 16777216 length 8388608
2017/06/02 11:08:19 DEBUG : 01_20170602033554000.MP4: Sending chunk 520093696 length 4266793
2017/06/02 11:08:20 DEBUG : 01_20170602040217000.MP4: Sending chunk 260046848 length 8388608
2017/06/02 11:08:20 ERROR : 01_20170602033554000.MP4: Failed to copy: googleapi: Error 404: File not found: 0B_raumxsbgcgYk9oOGhSSmZjcjg, notFound
2017/06/02 11:08:22 DEBUG : 01_20170602043157000.MP4: Sending chunk 0 length 8388608
 2017/06/02 11:08:23 DEBUG : 01_20170602043157000.MP4: Sending chunk 8388608 length 8388608
2017/06/02 11:08:24 DEBUG : 01_20170602035337000.MP4: Sending chunk 293601280 length 8388608
2017/06/02 11:08:24 DEBUG : 01_20170602043157000.MP4: Sending chunk 16777216 length 8388608
2017/06/02 11:08:25 DEBUG : 01_20170602042157000.MP4: Sending chunk 25165824 length 8388608
2017/06/02 11:08:26 DEBUG : 01_20170602040217000.MP4: Sending chunk 268435456 length 8388608
2017/06/02 11:08:27 DEBUG : 01_20170602043157000.MP4: Sending chunk 25165824 length 8388608
2017/06/02 11:08:29 DEBUG : 01_20170602043157000.MP4: Sending chunk 33554432 length 8388608
2017/06/02 11:08:29 DEBUG : 01_20170602035337000.MP4: Sending chunk 301989888 length 8388608
2017/06/02 11:08:30 DEBUG : 01_20170602040217000.MP4: Sending chunk 276824064 length 8388608
2017/06/02 11:08:30 DEBUG : 01_20170602042157000.MP4: Sending chunk 33554432 length 8388608
2017/06/02 11:08:32 DEBUG : 01_20170602043157000.MP4: Sending chunk 41943040 length 8388608
2017/06/02 11:08:33 DEBUG : 01_20170602035337000.MP4: Sending chunk 310378496 length 8388608

@gfrewqpoiu
Copy link

I also still have the 404 File not found issue. Some files seem to work fine while others, especially media don't. None of my mp3s transfer while text files and images mostly work. I have no Idea what is causing that though.

@timwhite
Copy link

timwhite commented Jun 3, 2017

2017/06/04 07:00:20 ERROR : 2013 RM MOTHERS DAY/MVI_7671.MOV: Failed to copy: googleapi: Error 404: File not found: 0B3vEQiiMiugPSEl5YUcySmdSWlE, notFound

It's interesting, it does appear to be failing on media.
I had apparently uploaded lots

Transferred:   146.201 GBytes (4.024 MBytes/s)
Errors:               435
Checks:                 6
Transferred:          591
Elapsed time:  10h20m0.5s

But rclone size reports

2017/06/04 06:59:04 INFO  : Google drive root '': Modify window is 1ms
Total objects: 632
Total size: 1.271 GBytes (1364891114 Bytes)

And browsing the uploaded files, I'm only really seeing documents, the occasional wav, but not the media. This upload us mostly media as we want to migrate a media share to a team drive.

@ncw
Copy link
Member

ncw commented Jun 3, 2017

Hmm, something is not quite right. I haven't seen a specific problem with media but I have seen the uploads just disappearing. I'll investigate some more and post another beta. I must have missed something in the team drive docs...

If someone could capture the http transaction which causes the file not found error that would be useful. Use -vv and --dump-bodies (or --dump-headers if that isn't practical)

@timwhite
Copy link

timwhite commented Jun 4, 2017

From what I can see, rclone has sanitised the debug output. dump-bodies put too much junk on my screen, probably because it was uploading a binary file, so I went with dump-headers
debugrclone.txt

The errors aren't consistent as to the filetype, it seems to happen more with larger files. Obviously media files are larger, so it happens more with those than small files. The particular directory I was trying to upload, having a look at what worked and didn't, anything over 8MB appears to have failed.

8.6M Mar 12  2012 IMG_9927.JPG

@timwhite
Copy link

timwhite commented Jun 4, 2017

Increasing --drive-upload-cutoff= so it doesn't transfer as chunked and the upload works

ncw added a commit that referenced this issue Jun 4, 2017
@ncw
Copy link
Member

ncw commented Jun 4, 2017

Thanks @timwhite that was very helpful. I missed a teamdrive change in the upload chunked files code. This beta fixes that so it should fix the "File not Found" problem.

https://pub.rclone.org/v1.36-156-gca76b3fb-team-drive%CE%B2/

@timwhite
Copy link

timwhite commented Jun 4, 2017

@ncw Thanks. I'll give that a test and see how it goes. Will know by morning if I have lots of failures or not!

@if1mad
Copy link

if1mad commented Jun 4, 2017

@ncw Unfortunately didn't work.

Here is a standard -vv https://pastebin.com/2cLGTtdg

and here's with dump-headers https://cryptobin.co/39a667c6 - too big for pastebin, pw is 123

ncw added a commit that referenced this issue Jun 4, 2017
@ncw
Copy link
Member

ncw commented Jun 4, 2017

@Qwatuz I don't think you are using the latest version - can you try this one: https://pub.rclone.org/v1.36-156-gca76b3fb-team-drive%CE%B2/ (note that the 156 is the same, but the ID is different).

@if1mad
Copy link

if1mad commented Jun 4, 2017

@ncw Aha my bad! I will give it a try later today (someone will most likely beat me to it). ;)

@juanrodgil
Copy link

It worked fine for me!

@zenjabba
Copy link

zenjabba commented Jun 4, 2017

I can tell you this version is working fine with Team Drive

@timwhite
Copy link

timwhite commented Jun 4, 2017

@ncw after 10 hours of copying, it's transferred > 100GB with no errors! :-D

Thanks for implementing Team Drives!

@gfrewqpoiu
Copy link

Already transferred 300 GB onto a team drive, thank you @ncw . Even Media works now. Chunked Upload and big files work fine. Only issue left is that during first configuration it always states Failed to save key for NICKNAME, no such section or something like that. It is still working fine though.

@ncw ncw closed this as completed in a5cfdfd Jun 4, 2017
@ncw
Copy link
Member

ncw commented Jun 4, 2017

Excellent - thanks for testing everyone.

I'll merge this to master so it will be in the general betas from now on.

@gfrewqpoiu wrote

Only issue left is that during first configuration it always states Failed to save key for NICKNAME, no such section or something like that.

I've made a new issue about that here #1466 as it affects all the oauth remotes. The message is harmless though.

The next beta will be here: https://beta.rclone.org/v1.36-158-ga5cfdfd2/ (uploaded in 15-30 mins).

@ncw ncw reopened this Jun 4, 2017
@dav1303
Copy link

dav1303 commented Jun 5, 2017

Hi

Well done tested to migrate with success from file server

Good job

@jwhitelbl
Copy link
Author

Successfully tested. My boss will be pretty freakin happy about this one. Thanks!

@TripleFrequency
Copy link

TripleFrequency commented Jun 18, 2017

@ncw
Is there a way you could integrate server-side copy between remotes if the team-drive is owned or shared to the other remote?

So, if you have your main GDrive "gdriveMain" and your teamdrive "gdriveTeamDrive", if you do "rclone copy gdriveMain:/TestFile.txt gdriveTeamDrive:/" then it would attempt a server-side copy instead?

As for testing whether it is possible, you could use the "capabilities.canCopy" from a Teamdrives.get request. Then, you could simply call a File.copy request of the file, with a "parents[]" section of the request body, simply containing the new destination.

Unfortunately, I lack the knowledge of Go to implement this myself.

@lazmo88
Copy link

lazmo88 commented Apr 7, 2018

Hello, I am trying to setup G Drive as a remote location by using Service Account. However when trying to access Team Drivers I get following error: Failed to configure team drive: list team drives failed: googleapi: Error 500: Internal Error, internalError

Does SA work with Team Drives or should I use personal access token in this case?

@jwhitelbl
Copy link
Author

I set up a new team endpoint the other day and ran into this. Give it 5-10 minutes after setting up the new endpoint and try again.

@lazmo88
Copy link

lazmo88 commented Apr 7, 2018

Thanks @gimpbully I will try again :) But in theory using Service Account should work also with Team Drives?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests