How to copy/bisync/update files only if they are newer

What is the problem you are having with rclone?

I would like to set rclone up to copy from local to remote and remote to local, only files that are newer.
Use case is to have binary file on google drive and want to use utility on many devices that could modify the file (locally and copy new version of it to remote).
Only one device at time will be updating the file. So there is no worry about any conflicts.
Other devices will later update their local file based on the remote file.

But I cant get it work without possibility to check for modification date.
For example I would like to achieve functionality of rsync -update
-u, --update skip files that are newer on the receiver

For example:

Local:
FileA - mod. date 23_06_15

Remote:
FileA - mod. date 23_06_16

When I run:

rclone [magic option] local_path remote:path
I would expect to do nothing

And when I run
rclone [magic option] remote:path local_path

I would expect it to replace local FileA with FileA from remote.

However when I am trying to use rclone copy or rclone sync I see no option to copy/sync only newer files, just --max-age that does not fit to my use-case.
Running
rclone copy /home/my/path my_remote:path/ --verbose
will simply replace FileA with older version from local and all newer changes are lost.

I found experimental function `rclone bisync, which is also not suitable for me need.

I would expect need for this functionality to be very popular. I am very surprised that rclone does not implement this functionality.
Am I missing something?

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

rclone v1.62.2
- os/version: ubuntu 22.04 (64 bit)
- os/kernel: 5.19.0-45-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.20.2
- go/linking: static
- go/tags: none

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

Google Drive

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

rclone copy /home/my/path my_remote:path/ --verbose
rclone copy my_remote:path/  /home/my/path --verbose
rclone sync /home/my/path my_remote:path/ --verbose
rclone sync my_remote:path/  /home/my/path --verbose

The rclone config contents with secrets removed.

[my_remote]
type = drive
scope = drive.file
auth_owner_only = true
token = {"access_token":"my-token","token_type":"Bearer","refresh_token":"refresh_toekn","expiry":"2023-06-28T16:48:49.453484981+02:00"}

A log from the command with the -vv flag

When they are identical:

$ rclone copy /home/my/path/ my_remote:path/ -vv
2023/06/29 09:24:16 DEBUG : rclone: Version "v1.62.2" starting with parameters ["rclone" "copy" "/home/my/path/" "my_remote:path/" "-vv"]
2023/06/29 09:24:16 DEBUG : Creating backend with remote "/home/my/path/"
2023/06/29 09:24:16 DEBUG : Using config file from "/home/my/.config/rclone/rclone.conf"
2023/06/29 09:24:16 DEBUG : fs cache: renaming cache item "/home/my/path/" to be canonical "/home/my/path"
2023/06/29 09:24:16 DEBUG : Creating backend with remote "my_remote:path/"
2023/06/29 09:24:17 DEBUG : Google drive root 'path': 'root_folder_id = root' - save this in the config to speed up startup
2023/06/29 09:24:17 DEBUG : fs cache: renaming cache item "my_remote:path/" to be canonical "my_remote:path/"
2023/06/29 09:24:17 DEBUG : FileA: Size and modification time the same (differ by 0s, within tolerance 1ms)
2023/06/29 09:24:17 DEBUG : FileA: Unchanged skipping
2023/06/29 09:24:17 DEBUG : Google drive root 'path': Waiting for checks to finish
2023/06/29 09:24:17 DEBUG : test2.txt: Size and modification time the same (differ by -616.119µs, within tolerance 1ms)
2023/06/29 09:24:17 DEBUG : test2.txt: Unchanged skipping
2023/06/29 09:24:17 DEBUG : Google drive root 'path': Waiting for transfers to finish
2023/06/29 09:24:17 INFO  : There was nothing to transfer
2023/06/29 09:24:17 INFO  : 
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Checks:                 2 / 2, 100%
Elapsed time:         0.7s

2023/06/29 09:24:17 DEBUG : 5 go routines active

When FileA is newer on remote and running copy from local to remote:

$rclone copy /home/my/path/ my_remote:path/ -vv

You can achieve it with bisync however it has its quirks - maybe this is why it is experimental. Initial --resync run seems not to respect modtime and just overwrites Path1 with Path2

make local empty folder:

rclone bisync local_path remote: --resync

now when files change and you run:

rclone bisync local_path remote:

it should behave as expected.

You can also run rclone copy with below flag:

-u, --update Skip files that are newer on the destination

1 Like

Thanks! The -u flag is what I was looking for.

However did not find it anywhere (docs, manual pages), thus never tried it.

2023/06/29 10:21:07 DEBUG : test2.txt: Destination is newer than source, skipping

1 Like

But rclone nowadays has so many flags that it is sometimes difficult to find the right one:)

1 Like

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