Use RClone to copy file to list of remote computers/locations

What is the problem you are having with rclone?

Need to feed a list of computers to RClone so it can copy a file to each.

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

rclone v1.57.0

  • os/version: Microsoft Windows 10 Enterprise 2009 (64 bit)
  • os/kernel: 10.0.19044.1706 (x86_64)
  • os/type: windows
  • os/arch: amd64
  • go/version: go1.17.2
  • go/linking: dynamic
  • go/tags: cmount

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

local network

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

rclone.exe sync "\\source" "\\destination"

The rclone config contents with secrets removed.

Paste config here

A log from the command with the -vv flag

Paste  log here

Does anyone have a suggestion on how to loop a list of machines to RClone and have it sync the file?

It is really appreciated!

What your looking for is probably to use rclone in a .bat file. Is this a one time thing or are you constantly pushing things to these computers?

I would be doing it quarterly. It is just too many machines to do it manually

--- what programming language do you plan to use, dos batch, powershell, python or what?
--- can you post a detailed example of such a command?
--- how many machines?

I am not opposed to dos or powershell. Not sure of a way to pipe it. The list could be about 250 computers, txt file one line each.

The command I have is simple right now, just the

rclone.exe sync "\source\file" "\destination\file"

Any help is greatly appreciated!

Good morning all,

Any idea how to pipe that command to a list.txt of computers? It is most appreciated!

Good morning,

Anyone able to assist with piping this to the list.txt file?

Thank you,

OK after some work this is what I came up with:

$ComputerList = Get-Content PC_LIST_TO_COPY_TO.txt
foreach ($Computer in $ComputerList) {
	cmd /c rclone.exe copy "c:\test" "\\$Computer\C$" --ignore-size --ignore-checksum --progress --log-file="c:\rclone\logs\rclone.log" --log-level=DEBUG
}

And I get an error:

2022/09/02 14:05:24 DEBUG : rclone: Version "v1.59.1" starting with parameters ["rclone.exe" "copy" "c:\test" "\\COMPUTERNAME\C$" "--ignore-size" "--ignore-checksum" "--progress" "--log-file=c:\rclone\logs\rclone.log" "--log-level=DEBUG"]
2022/09/02 14:05:24 DEBUG : Creating backend with remote "c:\test"
2022/09/02 14:05:24 DEBUG : Using config file from "C:\Users\wadewizard\AppData\Roaming\rclone\rclone.conf"
2022/09/02 14:05:24 DEBUG : fs cache: renaming cache item "c:\test" to be canonical "//?/c:/test"
2022/09/02 14:05:24 DEBUG : Creating backend with remote "\\COMPUTERNAME\C$"
2022/09/02 14:05:26 DEBUG : fs cache: renaming cache item "\\COMPUTERNAME\C$" to be canonical "//?/UNC/COMPUTERNAME/C$"
2022/09/02 14:05:26 DEBUG : Local file system at //?/UNC/COMPUTERNAME/C$: Waiting for checks to finish
2022/09/02 14:05:26 DEBUG : Local file system at //?/UNC/COMPUTERNAME/C$: Waiting for transfers to finish
2022/09/02 14:05:26 ERROR : FILETOCOPY.exe: Failed to copy: mkdir \?\UNC: The filename, directory name, or volume label syntax is incorrect.
2022/09/02 14:05:26 ERROR : Attempt 1/3 failed with 1 errors and: mkdir \?\UNC: The filename, directory name, or volume label syntax is incorrect.
2022/09/02 14:05:26 DEBUG : Local file system at //?/UNC/COMPUTERNAME/C$: Waiting for checks to finish
2022/09/02 14:05:26 DEBUG : Local file system at //?/UNC/COMPUTERNAME/C$: Waiting for transfers to finish
2022/09/02 14:05:26 ERROR : FILETOCOPY.exe: Failed to copy: mkdir \?\UNC: The filename, directory name, or volume label syntax is incorrect.
2022/09/02 14:05:26 ERROR : Attempt 2/3 failed with 1 errors and: mkdir \?\UNC: The filename, directory name, or volume label syntax is incorrect.
2022/09/02 14:05:26 DEBUG : Local file system at //?/UNC/COMPUTERNAME/C$: Waiting for checks to finish
2022/09/02 14:05:26 DEBUG : Local file system at //?/UNC/COMPUTERNAME/C$: Waiting for transfers to finish
2022/09/02 14:05:26 ERROR : FILETOCOPY.exe: Failed to copy: mkdir \?\UNC: The filename, directory name, or volume label syntax is incorrect.
2022/09/02 14:05:26 ERROR : Attempt 3/3 failed with 1 errors and: mkdir \?\UNC: The filename, directory name, or volume label syntax is incorrect.
2022/09/02 14:05:26 INFO :
Transferred: 0 B / 0 B, -, 0 B/s, ETA -
Errors: 1 (retrying may help)
Elapsed time: 2.4s

2022/09/02 14:05:26 DEBUG : 3 go routines active
2022/09/02 14:05:26 Failed to copy: mkdir \?\UNC: The filename, directory name, or volume label syntax is incorrect.

Any idea how to get it around this error?

i am going to guess that there is an escape issue with $"
with $Computer, if none of the values contain a space character, no need for quotes.

https://community.spiceworks.com/topic/2235034-help-with-script-to-read-a-list-of-computers-from-txt-and-run-commands-against

but @albertony might know.

Thank you.

I did find a powershell script that will do what I need, in fact it is what I built this one off.

$ComputerList = Get-Content PC_LIST_TO_COPY_TO.txt
foreach ($Computer in $ComputerList) {
Copy-Item -Path c:\FOLDER\PATH\TO\EDIT -Destination "\\$Computer\C$" -Recurse
}

It seems I am getting the same error, with or without quotes. I have also tried similar to

> "\\$Computer\C$\"

.

Thank you,

I think you commands are fine, but COMPUTERNAME in your log is not the name of a computer on the network...?

What if you try a simple command, such as ping or nslookup:

$ComputerList = Get-Content PC_LIST_TO_COPY_TO.txt
foreach ($Computer in $ComputerList) {
    nslookup $Computer
}

OH, that was just me replacing the information with a generic naming. It is definitely grabbing the correct computer name and displaying it in the logs. I just changed the computer name and the file name for uploading to the web.

The machines are on and pingable.

Thank you,

OK I got it. Your nslookup had me thinking. I had fed it a list of computer names, it seems to only work with a list of IPs.

$ComputerList = Get-Content LIST_OF_IP_TO_COPY_TO.txt
foreach ($Computer in $ComputerList) {
	cmd /c rclone.exe copy "c:\test" "\\$Computer\C$" --ignore-size --ignore-checksum --progress --log-file="c:\rclone\logs\rclone.log" --log-level=DEBUG
}

That was what I assumed, but my thinking was the error "Failed to copy: mkdir \?\UNC: The filename, directory name, or volume label syntax is incorrect.", I could reproduce that with something like rclone copy dir \\example.com\X$ -vv.

Great!

Thanks a bunch!

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