Union backend copying to all remotes while it shouldn't

What is the problem you are having with rclone?

I have two different (empty) shared drives in google drive which I want to merge together and copy files over them.
I'd like to make the load as equal as possible, so I choose the eplno create policy (i left the default epall for action and ff for search). For experimenting, I also tried the erand policy , but the result is the same.
To my understanding of things, eplno (or eprand) should choose ONE of the two remotes and rclone should copy a file into only ONE of the remotes.
rclone instead is copying the files into BOTH folders, which is effectively the same as the epall policy.
Is it me not getting how union works? Or is there a bug?

Run the command 'rclone version' and share the full output of the command.

rclone v1.59.0-beta.6340.62bcc84f6
- os/version: Microsoft Windows 11 Enterprise 22H2 (64 bit)
- os/kernel: 10.0.25151.1010 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.18.3
- go/linking: static
- go/tags: cmount

I used 1.59.0 beta because of this issue.

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

Two Team Drives merged with union, trying to copy a local folder

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

rclone copy .\Test_Folder\ gunion:\Test1951 -vvvvv -P

The rclone config contents with secrets removed.

[gone]
type = drive
client_id = redacted
client_secret = redacted
scope = drive
auth_owner_only = false
use_trash = true
skip_gdocs = true
skip_checksum_gphotos = true
upload_cutoff = 128Mi
chunk_size = 64Mi
acknowledge_abuse = true
server_side_across_configs = true
stop_on_upload_limit = true
stop_on_download_limit = true
token =redacted
team_drive = redacted

[gtwo]
type = drive
client_id = redacted
client_secret = redacted
scope = drive
auth_owner_only = false
use_trash = true
skip_gdocs = true
skip_checksum_gphotos = true
upload_cutoff = 128Mi
chunk_size = 64Mi
acknowledge_abuse = true
server_side_across_configs = true
stop_on_upload_limit = true
stop_on_download_limit = true
token = redacted
team_drive = redacted2
root_folder_id = 

[gunion]
type = union
upstreams = gone: gtwo:
create_policy = eprand
search_policy = epff
cache_time = 50
#tried both with and without action_policy
action_policy = eprand

A log from the command with the -vv flag

2022/07/08 19:51:26 DEBUG : rclone: Version "v1.59.0-beta.6340.62bcc84f6" starting with parameters ["c:\\windows\\system32\\rclone.exe" "copy" ".\\Test_Folder\\" "gunion:\\Test1951" "-vvvvv" "-P"]
2022/07/08 19:51:26 DEBUG : Creating backend with remote ".\\Test_Folder\\"
2022/07/08 19:51:26 DEBUG : Using config file from "C:\\Users\\Davide\\.config\\rclone\\rclone.conf"
2022/07/08 19:51:26 DEBUG : fs cache: renaming cache item ".\\Test_Folder\\" to be canonical "//?/D:/Downloads/Test_Folder"
2022/07/08 19:51:26 DEBUG : Creating backend with remote "gunion:\\Test1951"
2022/07/08 19:51:26 DEBUG : Creating backend with remote "gtwo:"
2022/07/08 19:51:26 DEBUG : Creating backend with remote "gone:"
2022/07/08 19:51:26 DEBUG : Creating backend with remote "gtwo:/Test1951"
2022/07/08 19:51:26 DEBUG : Creating backend with remote "gone:/Test1951"
2022/07/08 19:51:26 DEBUG : fs cache: renaming cache item "gtwo:/Test1951" to be canonical "gtwo:Test1951"
2022/07/08 19:51:26 DEBUG : fs cache: renaming cache item "gone:/Test1951" to be canonical "gone:Test1951"
2022/07/08 19:51:26 DEBUG : union root '/Test1951': actionPolicy = *policy.EpRand, createPolicy = *policy.EpRand, searchPolicy = *policy.EpFF
2022/07/08 19:51:26 DEBUG : fs cache: renaming cache item "gunion:\\Test1951" to be canonical "gunion:/Test1951"
2022-07-08 19:51:27 DEBUG : union root '/Test1951': Waiting for checks to finish
2022-07-08 19:51:27 DEBUG : union root '/Test1951': Waiting for transfers to finish
2022-07-08 19:51:28 DEBUG : Google drive root '': read info from Shared Drive "sd_02"
2022-07-08 19:51:28 DEBUG : Google drive root '': read info from Shared Drive "sd_02"
2022-07-08 19:51:28 DEBUG : Google drive root '': read info from Shared Drive "sd_01"
2022-07-08 19:51:29 DEBUG : Google drive root '': read info from Shared Drive "sd_01"
2022-07-08 19:51:36 DEBUG : file_b.txt: md5 = 918c6f47a5f309df1469397a0b656525 OK
2022-07-08 19:51:36 INFO  : file_b.txt: Copied (new)
2022-07-08 19:51:36 DEBUG : file_a.txt: md5 = 5e74bf3011d7eed034250d4bc8f7c27d OK
2022-07-08 19:51:36 INFO  : file_a.txt: Copied (new)
Transferred:             12 B / 12 B, 100%, 1 B/s, ETA 0s
Transferred:            2 / 2, 100%
Elapsed time:        10.3s
2022/07/08 19:51:36 INFO  :
Transferred:             12 B / 12 B, 100%, 1 B/s, ETA 0s
Transferred:            2 / 2, 100%
Elapsed time:        10.3s

2022/07/08 19:51:36 DEBUG : 19 go routines active

After this I expect to have either the files in gone: OR in gtwo: , but instead, I have them in both

PS D:\Downloads> rclone ls gunion:
        6 Test1951/file_a.txt
        6 Test1951/file_b.txt
PS D:\Downloads> rclone ls gone:
        6 Test1951/file_b.txt
        6 Test1951/file_a.txt
PS D:\Downloads> rclone ls gtwo:
        6 Test1951/file_b.txt
        6 Test1951/file_a.txt

edit: as a side note, i'm experiencing delays in google drive. The uploaded files will only appear many minutes after the upload. I don't know if it's my fault or if google has issues.

Hmm I wonder if those delays (which we've seen before of shared drives) are the cause of this problem.

Can you point your Union at two local directories to take the shared drives out of the equation and see if it behaves the same?

I can't write a comment that makes sense so i will let the shell speak for itself:

PS D:\Downloads\rclonetest> tree /f
D:.
β”œβ”€β”€β”€test_1
β”œβ”€β”€β”€test_2
└───Test_Folder
        file_a.txt
        file_b.txt

PS D:\Downloads\rclonetest> rclone copy .\Test_Folder test_u:
PS D:\Downloads\rclonetest> tree /f
D:.
β”œβ”€β”€β”€test_1
β”‚       file_b.txt
β”‚
β”œβ”€β”€β”€test_2
β”‚       file_a.txt
β”‚
└───Test_Folder
        file_a.txt
        file_b.txt

PS D:\Downloads\rclonetest> # as expected, every file goes to only one
PS D:\Downloads\rclonetest> del .\test_1\file_b.txt
PS D:\Downloads\rclonetest> del .\test_2\file_a.txt
PS D:\Downloads\rclonetest> rclone copy .\Test_Folder test_u:\Test0947
PS D:\Downloads\rclonetest> tree /f
D:.
β”œβ”€β”€β”€test_1
β”‚   └───Test0947
β”‚           file_a.txt
β”‚           file_b.txt
β”‚
β”œβ”€β”€β”€test_2
β”‚   └───Test0947
β”‚           file_a.txt
β”‚           file_b.txt
β”‚
└───Test_Folder
        file_a.txt
        file_b.txt

PS D:\Downloads\rclonetest> #!!!

edit: i forgot to put the config

[test_1]
type = local

[test_2]
type = local

[test_u]
type = union
upstreams = test_1:test_1 test_2:test_2
create_policy = eprand
search_policy = epff
cache_time = 50
action_policy = eprand

I have managed to replicate this.

It seems that the problem only occurs if the destination directory does not exist at the start.

Though I can only replicate this if the root directory does not exist at the start which is not quite what you are seeing.

rm -rf test_1 test_2 ; rclone copy -vv Test_Folder test_u: ; tree test_1 test_2

And this never replicates it

rm -rf test_1/* test_2/* ; rclone copy -vv Test_Folder test_u: ; tree test_1 test_2

Do you have a linux box you could test on to see if you get the same results?

Yep, I have the same results as you in Linux, and surprise! I also have the same results in Windows!

PS D:\Downloads\rclonetest> Remove-Item -Recurse -Path .\test_1\,.\test_2\ ; rclone copy -vv Test_Folder test_u: ; tree /f
2022/07/09 20:31:46 DEBUG : rclone: Version "v1.59.0-beta.6344.42dfadfa1" starting with parameters ["c:\\windows\\system32\\rclone.exe" "copy" "-vv" "Test_Folder" "test_u:"]
2022/07/09 20:31:46 DEBUG : Creating backend with remote "Test_Folder"
2022/07/09 20:31:46 DEBUG : Using config file from "C:\\Users\\Davide\\.config\\rclone\\rclone.conf"
2022/07/09 20:31:46 DEBUG : fs cache: renaming cache item "Test_Folder" to be canonical "//?/D:/Downloads/rclonetest/Test_Folder"
2022/07/09 20:31:46 DEBUG : Creating backend with remote "test_u:"
2022/07/09 20:31:46 DEBUG : Creating backend with remote "test_2:test_2"
2022/07/09 20:31:46 DEBUG : Creating backend with remote "test_1:test_1"
2022/07/09 20:31:46 DEBUG : fs cache: renaming cache item "test_1:test_1" to be canonical "test_1://?/D:/Downloads/rclonetest/test_1"
2022/07/09 20:31:46 DEBUG : fs cache: switching user supplied name "test_1:test_1" for canonical name "test_1://?/D:/Downloads/rclonetest/test_1"
2022/07/09 20:31:46 DEBUG : fs cache: renaming cache item "test_2:test_2" to be canonical "test_2://?/D:/Downloads/rclonetest/test_2"
2022/07/09 20:31:46 DEBUG : fs cache: switching user supplied name "test_2:test_2" for canonical name "test_2://?/D:/Downloads/rclonetest/test_2"
2022/07/09 20:31:46 DEBUG : union root '': actionPolicy = *policy.EpRand, createPolicy = *policy.EpRand, searchPolicy = *policy.EpFF
2022/07/09 20:31:46 DEBUG : union root '': Waiting for checks to finish
2022/07/09 20:31:46 DEBUG : union root '': Waiting for transfers to finish
2022/07/09 20:31:46 DEBUG : file_b.txt: md5 = 918c6f47a5f309df1469397a0b656525 OK
2022/07/09 20:31:46 INFO  : file_b.txt: Copied (new)
2022/07/09 20:31:46 DEBUG : file_a.txt: md5 = 5e74bf3011d7eed034250d4bc8f7c27d OK
2022/07/09 20:31:46 INFO  : file_a.txt: Copied (new)
2022/07/09 20:31:46 INFO  :
Transferred:             12 B / 12 B, 100%, 0 B/s, ETA -
Transferred:            2 / 2, 100%
Elapsed time:         0.0s

2022/07/09 20:31:46 DEBUG : 3 go routines active
D:.
β”œβ”€β”€β”€test_1
β”‚       file_a.txt
β”‚       file_b.txt
β”‚
β”œβ”€β”€β”€test_2
β”‚       file_a.txt
β”‚       file_b.txt
β”‚
└───Test_Folder
        file_a.txt
        file_b.txt
PS D:\Downloads\rclonetest> Remove-Item -Recurse -Path .\test_1\*,.\test_2\* ; rclone copy -vv Test_Folder test_u: ; tree /f
2022/07/09 20:31:55 DEBUG : rclone: Version "v1.59.0-beta.6344.42dfadfa1" starting with parameters ["c:\\windows\\system32\\rclone.exe" "copy" "-vv" "Test_Folder" "test_u:"]
2022/07/09 20:31:55 DEBUG : Creating backend with remote "Test_Folder"
2022/07/09 20:31:55 DEBUG : Using config file from "C:\\Users\\Davide\\.config\\rclone\\rclone.conf"
2022/07/09 20:31:55 DEBUG : fs cache: renaming cache item "Test_Folder" to be canonical "//?/D:/Downloads/rclonetest/Test_Folder"
2022/07/09 20:31:55 DEBUG : Creating backend with remote "test_u:"
2022/07/09 20:31:55 DEBUG : Creating backend with remote "test_2:test_2"
2022/07/09 20:31:55 DEBUG : Creating backend with remote "test_1:test_1"
2022/07/09 20:31:55 DEBUG : fs cache: renaming cache item "test_1:test_1" to be canonical "test_1://?/D:/Downloads/rclonetest/test_1"
2022/07/09 20:31:55 DEBUG : fs cache: switching user supplied name "test_1:test_1" for canonical name "test_1://?/D:/Downloads/rclonetest/test_1"
2022/07/09 20:31:55 DEBUG : fs cache: renaming cache item "test_2:test_2" to be canonical "test_2://?/D:/Downloads/rclonetest/test_2"
2022/07/09 20:31:55 DEBUG : fs cache: switching user supplied name "test_2:test_2" for canonical name "test_2://?/D:/Downloads/rclonetest/test_2"
2022/07/09 20:31:55 DEBUG : union root '': actionPolicy = *policy.EpRand, createPolicy = *policy.EpRand, searchPolicy = *policy.EpFF
2022/07/09 20:31:55 DEBUG : union root '': Waiting for checks to finish
2022/07/09 20:31:55 DEBUG : union root '': Waiting for transfers to finish
2022/07/09 20:31:55 DEBUG : file_a.txt: md5 = 5e74bf3011d7eed034250d4bc8f7c27d OK
2022/07/09 20:31:55 INFO  : file_a.txt: Copied (new)
2022/07/09 20:31:55 DEBUG : file_b.txt: md5 = 918c6f47a5f309df1469397a0b656525 OK
2022/07/09 20:31:55 INFO  : file_b.txt: Copied (new)
2022/07/09 20:31:55 INFO  :
Transferred:             12 B / 12 B, 100%, 0 B/s, ETA -
Transferred:            2 / 2, 100%
Elapsed time:         0.0s

2022/07/09 20:31:55 DEBUG : 3 go routines active
D:.
β”œβ”€β”€β”€test_1
β”‚       file_a.txt
β”‚       file_b.txt
β”‚
β”œβ”€β”€β”€test_2
└───Test_Folder
        file_a.txt
        file_b.txt

Which means, other than the bug happening when the root directory does not exist, the problem is when you copy the files into a directory which is not a root directory and does not exist and you preprend the direcotry with "\"

PS D:\Downloads\rclonetest> Remove-Item -Recurse -Path .\test_1\*,.\test_2\* ; rclone copy -vv Test_Folder test_u:Test ; tree /f
2022/07/09 20:40:16 DEBUG : rclone: Version "v1.59.0-beta.6344.42dfadfa1" starting with parameters ["c:\\windows\\system32\\rclone.exe" "copy" "-vv" "Test_Folder" "test_u:Test"]
2022/07/09 20:40:16 DEBUG : Creating backend with remote "Test_Folder"
2022/07/09 20:40:16 DEBUG : Using config file from "C:\\Users\\Davide\\.config\\rclone\\rclone.conf"
2022/07/09 20:40:16 DEBUG : fs cache: renaming cache item "Test_Folder" to be canonical "//?/D:/Downloads/rclonetest/Test_Folder"
2022/07/09 20:40:16 DEBUG : Creating backend with remote "test_u:Test"
2022/07/09 20:40:16 DEBUG : Creating backend with remote "test_2:test_2"
2022/07/09 20:40:16 DEBUG : Creating backend with remote "test_1:test_1"
2022/07/09 20:40:16 DEBUG : fs cache: renaming cache item "test_1:test_1" to be canonical "test_1://?/D:/Downloads/rclonetest/test_1"
2022/07/09 20:40:16 DEBUG : Creating backend with remote "test_1:test_1/Test"
2022/07/09 20:40:16 DEBUG : fs cache: renaming cache item "test_1:test_1/Test" to be canonical "test_1://?/D:/Downloads/rclonetest/test_1/Test"
2022/07/09 20:40:16 DEBUG : fs cache: renaming cache item "test_2:test_2" to be canonical "test_2://?/D:/Downloads/rclonetest/test_2"
2022/07/09 20:40:16 DEBUG : Creating backend with remote "test_2:test_2/Test"
2022/07/09 20:40:16 DEBUG : fs cache: renaming cache item "test_2:test_2/Test" to be canonical "test_2://?/D:/Downloads/rclonetest/test_2/Test"
2022/07/09 20:40:16 DEBUG : union root 'Test': actionPolicy = *policy.EpRand, createPolicy = *policy.EpRand, searchPolicy = *policy.EpFF
2022/07/09 20:40:16 DEBUG : union root 'Test': Waiting for checks to finish
2022/07/09 20:40:16 DEBUG : union root 'Test': Waiting for transfers to finish
2022/07/09 20:40:16 DEBUG : file_a.txt: md5 = 5e74bf3011d7eed034250d4bc8f7c27d OK
2022/07/09 20:40:16 INFO  : file_a.txt: Copied (new)
2022/07/09 20:40:16 DEBUG : file_b.txt: md5 = 918c6f47a5f309df1469397a0b656525 OK
2022/07/09 20:40:16 INFO  : file_b.txt: Copied (new)
2022/07/09 20:40:16 INFO  :
Transferred:             12 B / 12 B, 100%, 0 B/s, ETA -
Transferred:            2 / 2, 100%
Elapsed time:         0.0s

2022/07/09 20:40:16 DEBUG : 3 go routines active
D:.
β”œβ”€β”€β”€test_1
β”‚   └───Test
β”‚           file_b.txt
β”‚
β”œβ”€β”€β”€test_2
β”‚   └───Test
β”‚           file_a.txt
β”‚
└───Test_Folder
        file_a.txt
        file_b.txt
PS D:\Downloads\rclonetest> #OK
PS D:\Downloads\rclonetest> Remove-Item -Recurse -Path .\test_1\*,.\test_2\* ; rclone copy -vv Test_Folder test_u:\Test ; tree /f
2022/07/09 20:40:22 DEBUG : rclone: Version "v1.59.0-beta.6344.42dfadfa1" starting with parameters ["c:\\windows\\system32\\rclone.exe" "copy" "-vv" "Test_Folder" "test_u:\\Test"]
2022/07/09 20:40:22 DEBUG : Creating backend with remote "Test_Folder"
2022/07/09 20:40:22 DEBUG : Using config file from "C:\\Users\\Davide\\.config\\rclone\\rclone.conf"
2022/07/09 20:40:22 DEBUG : fs cache: renaming cache item "Test_Folder" to be canonical "//?/D:/Downloads/rclonetest/Test_Folder"
2022/07/09 20:40:22 DEBUG : Creating backend with remote "test_u:\\Test"
2022/07/09 20:40:22 DEBUG : Creating backend with remote "test_2:test_2"
2022/07/09 20:40:22 DEBUG : Creating backend with remote "test_1:test_1"
2022/07/09 20:40:22 DEBUG : fs cache: renaming cache item "test_2:test_2" to be canonical "test_2://?/D:/Downloads/rclonetest/test_2"
2022/07/09 20:40:22 DEBUG : Creating backend with remote "test_2:test_2/Test"
2022/07/09 20:40:22 DEBUG : fs cache: renaming cache item "test_1:test_1" to be canonical "test_1://?/D:/Downloads/rclonetest/test_1"
2022/07/09 20:40:22 DEBUG : Creating backend with remote "test_1:test_1/Test"
2022/07/09 20:40:22 DEBUG : fs cache: renaming cache item "test_2:test_2/Test" to be canonical "test_2://?/D:/Downloads/rclonetest/test_2/Test"
2022/07/09 20:40:22 DEBUG : fs cache: renaming cache item "test_1:test_1/Test" to be canonical "test_1://?/D:/Downloads/rclonetest/test_1/Test"
2022/07/09 20:40:22 DEBUG : union root '/Test': actionPolicy = *policy.EpRand, createPolicy = *policy.EpRand, searchPolicy = *policy.EpFF
2022/07/09 20:40:22 DEBUG : fs cache: renaming cache item "test_u:\\Test" to be canonical "test_u:/Test"
2022/07/09 20:40:22 DEBUG : union root '/Test': Waiting for checks to finish
2022/07/09 20:40:22 DEBUG : union root '/Test': Waiting for transfers to finish
2022/07/09 20:40:22 DEBUG : file_b.txt: md5 = 918c6f47a5f309df1469397a0b656525 OK
2022/07/09 20:40:22 INFO  : file_b.txt: Copied (new)
2022/07/09 20:40:22 DEBUG : file_a.txt: md5 = 5e74bf3011d7eed034250d4bc8f7c27d OK
2022/07/09 20:40:22 INFO  : file_a.txt: Copied (new)
2022/07/09 20:40:22 INFO  :
Transferred:             12 B / 12 B, 100%, 0 B/s, ETA -
Transferred:            2 / 2, 100%
Elapsed time:         0.0s

2022/07/09 20:40:22 DEBUG : 3 go routines active
D:.
β”œβ”€β”€β”€test_1
β”‚   └───Test
β”‚           file_a.txt
β”‚           file_b.txt
β”‚
β”œβ”€β”€β”€test_2
β”‚   └───Test
β”‚           file_a.txt
β”‚           file_b.txt
β”‚
└───Test_Folder
        file_a.txt
        file_b.txt

PS D:\Downloads\rclonetest> # Not OK

Looks like a very corner case which I somehow managed to hit. :slight_smile:

Ah-ha - thats what I was missing - the prepended with / directory.

I've managed to discover where the problem is coming in with the missing root directories. I think that is probably a relatively minor problem as people don't often start with remotes which don't exist.

The prepended with / is more of a problem.

I think it is to do with sloppy path handling in the union backend... Let me see...

I think I've managed to fix both of those problems - give this a go

v1.60.0-beta.6351.013eaad3d.fix-union on branch fix-union (uploaded in 15-30 mins)

Thank you! The locals seem to be fixed, I will see about shared drives later.
Congratulations for the release of 1.59 and I'm happy these fixes start the 1.60 development cycle :smiley:

I've merged this to master now which means it will be in the latest beta in 15-30 minutes and released in v1.60. I'll probably put these fixes into a 1.59.1 in due course too.

1 Like

Thank you -- I checked with the shared drives and it works.

Anyway - Is it possible to apply the policies at a folder level instead of a file level? When I copy a directory (with eprand), the directory is created in almost all the remotes, and files are evenly distributed (and this is how it's supposed to work and it's fine) - but I'd like to have the directory and the files copied in only one remote, but when i copy another directory it would switch to another remote -- if I understood correctly this is not possible (at the moment)

I think eprand should be doing this already, with the exception of the root of the transfer where it will create all the directories. This is possibly a mistake!

Can you give an example?

You are indeed correct, I was only looking at the root of the transfer.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.