Output Current Processing File To Debug Log

The log file created with --log-file does not include the current file being processed even at the highest verbosity level. A log entry is made after processing of the file has completed. Logging the file before processing it allows the following scenarios:

  1. User can tail the log to follow current progress instead of only completed progress
  2. User can tell which file may be incomplete/corrupted if rclone is abnormally terminated

Proposed logging additions with new entries prefixed with <new>.

Edit: Apologies. I meant to put this in the Feature category.

<new> 2023/04/02 11:33:03 DEBUG : test4.txt: Copying
2023/04/02 11:33:03 DEBUG : test4.txt: md5 = 1e2db57dd6527ad4f8f281ab028d2c70 OK
2023/04/02 11:33:03 INFO  : test4.txt: Copied (new)
<new> 2023/04/02 11:33:03 DEBUG : test.txt: Copying
2023/04/02 11:33:03 DEBUG : test.txt: md5 = 1e2db57dd6527ad4f8f281ab028d2c70 OK
2023/04/02 11:33:03 INFO  : test.txt: Copied (new)
<new> 2023/04/02 11:33:03 DEBUG : test2.txt: Copying
2023/04/02 11:33:03 DEBUG : test2.txt: md5 = 1e2db57dd6527ad4f8f281ab028d2c70 OK
2023/04/02 11:33:03 INFO  : test2.txt: Copied (new)

It does:

[felix@gemini data]$ fallocate -l 10G testfile
[felix@gemini data]$ rclone copy testfile DB: -vv
2023/04/02 14:55:36 DEBUG : Setting --config "/opt/rclone/rclone.conf" from environment variable RCLONE_CONFIG="/opt/rclone/rclone.conf"
2023/04/02 14:55:36 DEBUG : rclone: Version "v1.62.2" starting with parameters ["rclone" "copy" "testfile" "DB:" "-vv"]
2023/04/02 14:55:36 DEBUG : Creating backend with remote "testfile"
2023/04/02 14:55:36 DEBUG : Using config file from "/opt/rclone/rclone.conf"
2023/04/02 14:55:36 DEBUG : fs cache: adding new entry for parent of "testfile", "/data"
2023/04/02 14:55:36 DEBUG : Creating backend with remote "DB:"
2023/04/02 14:55:36 DEBUG : DB: Loaded invalid token from config file - ignoring
2023/04/02 14:55:36 DEBUG : Saving config "token" in section "DB" of the config file
2023/04/02 14:55:36 DEBUG : Keeping previous permissions for config file: -rwxrwxr-x
2023/04/02 14:55:36 DEBUG : DB: Saved new token in config file
2023/04/02 14:55:36 DEBUG : testfile: Need to transfer - File not found at Destination
2023/04/02 14:55:37 DEBUG : testfile: Uploading chunk 1/160
2023/04/02 14:55:38 DEBUG : testfile: Uploading chunk 2/160
2023/04/02 14:55:41 DEBUG : testfile: Uploading chunk 3/160

Depends on the backend as well a bit.

Normally, that's done via exit codes when a program exits.

echo $?

as an example.

As you said, it does appear to be dependent upon the backend. If there is multipart copying being done, each part is logged. However, in the case of local to local copying without segmenting/chunking, no logging is provided until completion of the file. If there was a fixed log statement at the start of a file's processing and not on each chunk/segment uploaded it would cover all scenarios.

Not sure as I don’t use it for local as for me, it’s a cloud tool.

Debug shows it needs to transfer and then since it's instant, it copies:

 rclone copy /etc/hosts /home/felix/test -vvv
2023/04/02 17:08:36 DEBUG : Setting --config "/opt/rclone/rclone.conf" from environment variable RCLONE_CONFIG="/opt/rclone/rclone.conf"
2023/04/02 17:08:36 DEBUG : rclone: Version "v1.62.2" starting with parameters ["rclone" "copy" "/etc/hosts" "/home/felix/test" "-vvv"]
2023/04/02 17:08:36 DEBUG : Creating backend with remote "/etc/hosts"
2023/04/02 17:08:36 DEBUG : Using config file from "/opt/rclone/rclone.conf"
2023/04/02 17:08:36 DEBUG : fs cache: adding new entry for parent of "/etc/hosts", "/etc"
2023/04/02 17:08:36 DEBUG : Creating backend with remote "/home/felix/test"
2023/04/02 17:08:36 DEBUG : hosts: Need to transfer - File not found at Destination
2023/04/02 17:08:36 DEBUG : hosts: md5 = 54a8094ba057c05f9d5901847bdb3f1e OK
2023/04/02 17:08:36 INFO  : hosts: Copied (new)
2023/04/02 17:08:36 INFO  :
Transferred:   	        390 B / 390 B, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         0.0s

2023/04/02 17:08:36 DEBUG : 4 go routines active

Using bwlimit to show the time discrepancy.
5 second gap during copying.
Afterwards md5 and copied info log are shown.
No log of file beforehand.

Maybe this is a Windows specific issue?

D:\Scratch\rclonetest>rclone copy local\left\ local\right --bwlimit 100M -vv
2023/04/02 16:10:56 INFO  : Starting bandwidth limiter at 100Mi Byte/s
2023/04/02 16:10:56 DEBUG : rclone: Version "v1.62.2" starting with parameters ["rclone" "copy" "local\\left\\" "local\\right" "--bwlimit" "100M" "-vv"]
2023/04/02 16:10:56 DEBUG : Creating backend with remote "local\\left\\"
2023/04/02 16:10:56 DEBUG : Using config file from "C:\\Users\\fjih\\AppData\\Roaming\\rclone\\rclone.conf"
2023/04/02 16:10:56 DEBUG : fs cache: renaming cache item "local\\left\\" to be canonical "//?/D:/Scratch/rclonetest/local/left"
2023/04/02 16:10:56 DEBUG : Creating backend with remote "local\\right"
2023/04/02 16:10:56 DEBUG : fs cache: renaming cache item "local\\right" to be canonical "//?/D:/Scratch/rclonetest/local/right"
2023/04/02 16:10:56 DEBUG : Local file system at //?/D:/Scratch/rclonetest/local/right: Waiting for checks to finish
2023/04/02 16:10:56 DEBUG : Local file system at //?/D:/Scratch/rclonetest/local/right: Waiting for transfers to finish
2023/04/02 16:11:01 DEBUG : file.dat: md5 = cfe3665146e96c6e24818adde12139ff OK
2023/04/02 16:11:01 INFO  : file.dat: Copied (new)
2023/04/02 16:11:01 INFO  :
Transferred:      535.702 MiB / 535.702 MiB, 100%, 99.900 MiB/s, ETA 0s
Transferred:            1 / 1, 100%
Elapsed time:         5.5s

2023/04/02 16:11:01 DEBUG : 3 go routines active

Seems that way as I do really do Windows :slight_smile:

hi,

nope, not a windows issue, this time


rclone does not log the start of the hash calculation.
so maybe something like

2023/04/02 16:10:56 DEBUG : file.dat: Calculating hash
2023/04/02 16:11:01 DEBUG : file.dat: Starting upload
2023/04/02 16:11:01 DEBUG : file.dat: md5 = cfe3665146e96c6e24818adde12139ff OK
2023/04/02 16:11:01 INFO  : file.dat: Copied (new)

or more concise

2023/04/02 16:10:56 DEBUG : file.dat: Calculate hash and start transfer 
2023/04/02 16:11:01 DEBUG : file.dat: md5 = cfe3665146e96c6e24818adde12139ff OK
2023/04/02 16:11:01 INFO  : file.dat: Copied (new)

This would be the line missing on Windows.

hi,

imho, rclone behavior is different:
--- copy a single file - Need to transfer is displayed
or
--- copy a dir - Need to transfer is not displayed

+ rclone copy /root/files/source/file.ext /root/files/dest -vv
2023/04/02 20:24:40 DEBUG : rclone: Version "v1.62.2" starting with parameters ["rclone" "copy" "/root/files/source/file.ext" "/root/files/dest" "-vv"]
2023/04/02 20:24:40 DEBUG : Creating backend with remote "/root/files/source/file.ext"
2023/04/02 20:24:40 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2023/04/02 20:24:40 DEBUG : fs cache: adding new entry for parent of "/root/files/source/file.ext", "/root/files/source"
2023/04/02 20:24:40 DEBUG : Creating backend with remote "/root/files/dest"
2023/04/02 20:24:40 DEBUG : file.ext: Need to transfer - File not found at Destination
2023/04/02 20:24:40 DEBUG : file.ext: md5 = c4ca4238a0b923820dcc509a6f75849b OK
2023/04/02 20:24:40 INFO  : file.ext: Copied (new)
2023/04/02 20:24:40 INFO  : 
Transferred:   	          1 B / 1 B, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         0.1s

+ rclone delete /root/files/dest -v
2023/04/02 20:24:40 INFO  : file.ext: Deleted

+ rclone copy /root/files/source /root/files/dest -vv
2023/04/02 20:24:40 DEBUG : rclone: Version "v1.62.2" starting with parameters ["rclone" "copy" "/root/files/source" "/root/files/dest" "-vv"]
2023/04/02 20:24:40 DEBUG : Creating backend with remote "/root/files/source"
2023/04/02 20:24:40 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2023/04/02 20:24:40 DEBUG : Creating backend with remote "/root/files/dest"
2023/04/02 20:24:40 DEBUG : Local file system at /root/files/dest: Waiting for checks to finish
2023/04/02 20:24:40 DEBUG : Local file system at /root/files/dest: Waiting for transfers to finish
2023/04/02 20:24:40 DEBUG : file.ext: md5 = c4ca4238a0b923820dcc509a6f75849b OK
2023/04/02 20:24:40 INFO  : file.ext: Copied (new)
2023/04/02 20:24:40 INFO  : 
Transferred:   	          1 B / 1 B, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         0.1s

https://github.com/rclone/rclone/blob/f4c787ab74c1efe0eb242b3e867cc20b9ddb61c9/cmd/copy/copy.go#L90

		cmd.Run(true, true, command, func() error {
			if srcFileName == "" {
				return sync.CopyDir(context.Background(), fdst, fsrc, createEmptySrcDirs)
			}
			return operations.CopyFile(context.Background(), fdst, fsrc, srcFileName, srcFileName)
		})

https://github.com/rclone/rclone/blob/f4c787ab74c1efe0eb242b3e867cc20b9ddb61c9/fs/operations/operations.go#L1640

with CopyFile, rclone outputs
fs.Debugf(src, "Need to transfer - File not found at Destination")

So it's missing right?

right, it is missing.
tho, this time, not a windows issue, there must be --magic in the air!

as for a fix, maybe need to add
fs.Debugf(src, "Need to transfer - File not found at Destination")
to
sync.CopyDir()

Yes you are right these logs are missing. That is because the file bypasses the NeedsTransfer check if it exists in the source and not the destination and it is NeedsTransfer which prints the logs.

It needed fixing twice, once for --track-renames and once without.

Have a go with this and see what you think?

v1.63.0-beta.6933.6178e407e.fix-sync-logs on branch fix-sync-logs (uploaded in 15-30 mins)

based on my testing up above and the source code changes,
i assume, we only need to test when the source is a dir.

the results looks good to me.

i tested using this script.
note: i never used track-renames before, not sure my test is valid.

set -x

source=~/files/source
dest=~/files/dest

function setup {
./rclone delete $source
./rclone delete $dest

# same filename, same content
echo 'same.file' > $source/same.file
echo 'same.file' > $dest/same.file

# same filename, different content
echo 'differ.source' > $source/differ
echo 'differ.dest' > $dest/differ

# different filename, same content to test track-renames
echo 'same.conents' > $source/track.source.file
echo 'same.conents' > $dest/track.dest.file

# test missing files on source and dest
echo 'missing.on.dest' > $source/missing.on.dest
echo 'missing.on.source' > $dest/missing.on.source
}

setup
./rclone sync $source $dest -vv
setup
./rclone sync $source $dest --track-renames -vv

and here is the outputs

./rclone sync /root/files/source /root/files/dest -vv
2023/04/03 11:21:13 DEBUG : rclone: Version "v1.63.0-beta.6933.6178e407e.fix-sync-logs" starting with parameters ["./rclone" "sync" "/root/files/source" "/root/files/dest" "-vv"]
2023/04/03 11:21:13 DEBUG : Creating backend with remote "/root/files/source"
2023/04/03 11:21:13 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2023/04/03 11:21:13 DEBUG : Creating backend with remote "/root/files/dest"
2023/04/03 11:21:13 DEBUG : missing.on.dest: Need to transfer - File not found at Destination
2023/04/03 11:21:13 DEBUG : track.source.file: Need to transfer - File not found at Destination
2023/04/03 11:21:13 DEBUG : differ: Sizes differ (src 14 vs dst 12)
2023/04/03 11:21:13 DEBUG : Local file system at /root/files/dest: Waiting for checks to finish
2023/04/03 11:21:13 DEBUG : same.file: Size and modification time the same (differ by 0s, within tolerance 1ns)
2023/04/03 11:21:13 DEBUG : track.source.file: md5 = 69560bcf3a8ea14317b74c4adc7709cb OK
2023/04/03 11:21:13 DEBUG : same.file: Unchanged skipping
2023/04/03 11:21:13 INFO  : track.source.file: Copied (new)
2023/04/03 11:21:13 DEBUG : Local file system at /root/files/dest: Waiting for transfers to finish
2023/04/03 11:21:13 DEBUG : missing.on.dest: md5 = a21b4a9ca47717eac8b820fa58dbc239 OK
2023/04/03 11:21:13 INFO  : missing.on.dest: Copied (new)
2023/04/03 11:21:13 DEBUG : differ: md5 = aa3e7d3799f0801835eb6ba3248e8867 OK
2023/04/03 11:21:13 INFO  : differ: Copied (replaced existing)
2023/04/03 11:21:13 DEBUG : Waiting for deletions to finish
2023/04/03 11:21:13 INFO  : missing.on.source: Deleted
2023/04/03 11:21:13 INFO  : track.dest.file: Deleted
2023/04/03 11:21:13 INFO  : 
Transferred:   	         43 B / 43 B, 100%, 0 B/s, ETA -
Checks:                 4 / 4, 100%
Deleted:                2 (files), 0 (dirs)
Transferred:            3 / 3, 100%
Elapsed time:         0.1s

and

2023/04/03 11:21:14 DEBUG : rclone: Version "v1.63.0-beta.6933.6178e407e.fix-sync-logs" starting with parameters ["./rclone" "sync" "/root/files/source" "/root/files/dest" "--track-renames" "-vv"]
2023/04/03 11:21:14 DEBUG : Creating backend with remote "/root/files/source"
2023/04/03 11:21:14 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2023/04/03 11:21:14 DEBUG : Creating backend with remote "/root/files/dest"
2023/04/03 11:21:14 INFO  : Local file system at /root/files/dest: Making map for --track-renames
2023/04/03 11:21:14 DEBUG : same.file: Size and modification time the same (differ by 0s, within tolerance 1ns)
2023/04/03 11:21:14 DEBUG : same.file: Unchanged skipping
2023/04/03 11:21:14 DEBUG : differ: Sizes differ (src 14 vs dst 12)
2023/04/03 11:21:14 INFO  : Local file system at /root/files/dest: Finished making map for --track-renames
2023/04/03 11:21:14 DEBUG : Local file system at /root/files/dest: Waiting for checks to finish
2023/04/03 11:21:14 DEBUG : missing.on.dest: Need to transfer - No matching file found at Destination
2023/04/03 11:21:14 DEBUG : differ: md5 = aa3e7d3799f0801835eb6ba3248e8867 OK
2023/04/03 11:21:14 INFO  : differ: Copied (replaced existing)
2023/04/03 11:21:14 DEBUG : Local file system at /root/files/dest: Waiting for renames to finish
2023/04/03 11:21:14 INFO  : track.dest.file: Moved (server-side) to: track.source.file
2023/04/03 11:21:14 INFO  : track.source.file: Renamed from "track.dest.file"
2023/04/03 11:21:14 DEBUG : Local file system at /root/files/dest: Waiting for transfers to finish
2023/04/03 11:21:14 DEBUG : missing.on.dest: md5 = a21b4a9ca47717eac8b820fa58dbc239 OK
2023/04/03 11:21:14 INFO  : missing.on.dest: Copied (new)
2023/04/03 11:21:14 DEBUG : Waiting for deletions to finish
2023/04/03 11:21:14 INFO  : missing.on.source: Deleted
2023/04/03 11:21:14 INFO  : 
Transferred:   	         43 B / 43 B, 100%, 0 B/s, ETA -
Checks:                 5 / 5, 100%
Deleted:                1 (files), 0 (dirs)
Renamed:                1
Transferred:            2 / 2, 100%
Elapsed time:         0.1s

Thanks Nick. Branched version works on my end. Tested with copy and sync without --track-renames.

Thanks for testing :slight_smile:

I've merged this to master now which means it will be in the latest beta in 15-30 minutes and released in v1.63

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