Currently, Rclone seems to always attempt to create a new folder in the target. For example, I see this when attempting a server-side move from a user's My Drive to a shared drive in the same organization:
This behavior doesn't match what happens in the UI if I drag and drop the Source2 folder from My Drive into the shared drive. In the UI case, the folder is re-parented, and all sharing permissions are thus preserved.
I should note that re-parenting works here because the shared drive is in the same organization as the My Drive. If it were instead in a different organization, that operation would presumably fail because the corresponding UI case also fails.
My proposal is thus to try either of these approaches:
If the organization identity can be determined, compare the source and target to see if they are in the same organization. If they are, use re-parenting.
If the organization identity cannot be determined, first try to re-parent a folder and fall back to creating a new one if it fails.
I think rclone does reparent the directory when using the DirMove primitive
Which kind of suggests that somehow rclone avoided it for your example.
Can you post the command line you used, the redacted config and a log with -vv from your example?
Rclone has the --server-side-across-configs flag which enables this sort of server side move as I've never been able to reliably determine whether they are going to work or not.
2022/12/22 08:43:42 DEBUG : Creating backend with remote "Source:"
2022/12/22 08:43:42 DEBUG : Using config file from "C:\\Users\\Chad\\AppData\\Local\\Temp\\tmpBB5D.tmp"
2022/12/22 08:43:42 DEBUG : Source: detected overridden config - adding "{EW92g}" suffix to name
2022/12/22 08:43:43 DEBUG : Google drive root '': 'root_folder_id = 0AJMfyeX0r9BWUk9PVA' - save this in the config to speed up startup
2022/12/22 08:43:43 DEBUG : fs cache: renaming cache item "Source:" to be canonical "Source{EW92g}:"
2022/12/22 08:43:43 DEBUG : Creating backend with remote "Temp:"
2022/12/22 08:43:43 DEBUG : Temp: detected overridden config - adding "{EW92g}" suffix to name
2022/12/22 08:43:43 DEBUG : fs cache: renaming cache item "Temp:" to be canonical "Temp{EW92g}:"
2022/12/22 08:43:43 INFO : Google drive root '': Running all checks before starting transfers
2022/12/22 08:43:43 DEBUG : Google drive root '': read info from Shared Drive "Intermediate2"
2022/12/22 08:43:44 DEBUG : Google drive root '': Waiting for checks to finish
2022/12/22 08:43:44 INFO : Google drive root '': Checks finished, now starting transfers
2022/12/22 08:43:44 DEBUG : Google drive root '': Waiting for transfers to finish
2022/12/22 08:43:46 INFO : Directory1/sample2.txt: Moved (server-side)
2022/12/22 08:43:46 DEBUG : Directory1: Making directory
2022/12/22 08:43:46 DEBUG : Google drive root '': copied 1 directories
2022/12/22 08:43:46 INFO : Directory1: Removing directory
2022/12/22 08:43:47 DEBUG : Google drive root '': deleted 1 directories
2022/12/22 08:43:47 INFO : There was nothing to transfer
2022/12/22 08:43:47 INFO : 2022/12/22 08:43:47 - 21 B / 21 B, 100%, 0 B/s, ETA -
2022/12/22 08:43:47 DEBUG : 10 go routines active
2022/12/23 09:53:42 DEBUG : Creating backend with remote "Source:Folder1"
2022/12/23 09:53:42 DEBUG : Using config file from "C:\\Users\\Chad\\AppData\\Local\\Temp\\tmp4C22.tmp"
2022/12/23 09:53:42 DEBUG : Source: detected overridden config - adding "{EW92g}" suffix to name
2022/12/23 09:53:42 DEBUG : Google drive root 'Folder1': 'root_folder_id = 0AJMfyeX0r9BWUk9PVA' - save this in the config to speed up startup
2022/12/23 09:53:42 DEBUG : fs cache: renaming cache item "Source:Folder1" to be canonical "Source{EW92g}:Folder1"
2022/12/23 09:53:42 DEBUG : Creating backend with remote "Temp:Folder1"
2022/12/23 09:53:42 DEBUG : Temp: detected overridden config - adding "{EW92g}" suffix to name
2022/12/23 09:53:43 DEBUG : fs cache: renaming cache item "Temp:Folder1" to be canonical "Temp{EW92g}:Folder1"
2022/12/23 09:53:43 INFO : Google drive root 'Folder1': Running all checks before starting transfers
2022/12/23 09:53:44 DEBUG : Google drive root 'Folder1': Waiting for checks to finish
2022/12/23 09:53:44 INFO : Google drive root 'Folder1': Checks finished, now starting transfers
2022/12/23 09:53:44 DEBUG : Google drive root 'Folder1': Waiting for transfers to finish
2022/12/23 09:53:45 INFO : sample1.txt: Moved (server-side)
2022/12/23 09:53:45 INFO : There was nothing to transfer
2022/12/23 09:53:45 INFO : 2022/12/23 09:53:45 - 21 B / 21 B, 100%, 0 B/s, ETA -
2022/12/23 09:53:45 DEBUG : 10 go routines active
Any ideas why I don't see that in my case? Even if I can get the single-directory approach to work, it wouldn't solve my use case, in which I don't know the directories to move ahead of time. My goal is to server-side move all directories that happen to be there, whatever they are.
Can you try your example with moveto like I did? I wonder if that is the difference?
DirMove can't move the root directory - I just checked. Can you arrange to move from the directory above?
If rclone can't DirMove it will Move each individual file which is what you are seeing. I'm not sure why DirMove isn't kicking in for you - if you are able, tracing the flow of rclone would be useful here to figure out why!
It could be Move each file and DirMove each directory in the root of the transfer - I think this is more what you want to achieve.
DirMove isn't being used because the source and target configs are different, yet both are Google Drive. Here's what I see with some added logging:
2022/12/24 09:35:16 operations.go:726: DEBUG : Google drive root '': SameConfig(Target{rO-Pz}, Source{rO-Pz})
2022/12/24 09:35:16 operations.go:726: DEBUG : Google drive root '': SameConfig(Source{rO-Pz}, Target{rO-Pz})
2022/12/24 09:35:16 sync.go:1151: DEBUG : Google drive root '': Can't server-side directory move. sameConfig is false
If I remove that check, it gets past the block on the server-side directory move, but it fails when trying to move the drive root, just as you said it would.
2022/12/24 09:37:39 operations.go:726: DEBUG : Google drive root '': SameConfig(Target{rO-Pz}, Source{rO-Pz})
2022/12/24 09:37:39 sync.go:1146: INFO : Google drive root '': Test 2
2022/12/24 09:37:39 sync.go:1150: DEBUG : Google drive root '': Using server-side directory move
2022/12/24 09:37:39 sync.go:1160: ERROR : Google drive root '': Server side directory move failed: can't move root directory
2022/12/24 09:37:39 cmd.go:283: ERROR : Attempt 1/1 failed with 1 errors and: can't move root directory
2022/12/24 09:37:39 stats.go:484: INFO : 2022/12/24 09:37:39 - 0 B / 0 B, -, 0 B/s, ETA -
2022/12/24 09:37:39 cmd.go:298: DEBUG : 10 go routines active
2022/12/24 09:37:39 cmd.go:334: Failed to move: can't move root directory
Two questions:
What is the rationale behind restricting server-side moves to an identical configuration, even if the differing source and target are the same backend?
How can I server-side move anything inside the drive root without knowing what is there and without using filters, which I believe also causes server-side moves to be disabled?
This seems like a dead end until Google allows the same UI behavior via the API or somebody reverse-engineers the internal APIs used in the UI approach.