Is there a way to only update existing files?

Template not applicable.

Hello, is there a way to only copy/update files that already exist at the destination?
Something similar to rsync's --existing :

--existing              skip creating new files on receiver

Use case :
Two computers, A and B, sync to the same Remote.
Computer A makes a bunch of changes to existing files, that computer B needs to pull. Computer A also adds a new, large file, that needs to be synced to Remote for backup purposes, but is not required on computer B.
Remote is Google Drive.

Excluding the large file using --exclude is not an option, as practically, in the real world, it's not just a large file but rather an assortment of files under different directories that can't be actively monitored to be excluded and the file structure can't be changed to, say, have all excluded files in an "excluded" folder, for easy filtering.

Sure.

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

https://rclone.org/flags/

hello and welcome to the forum,

so if file.txt exists in the source but not the dest, then do not copy file.txt from source to dest, is that correct?

i could be wrong, but i do not think rclone has such a flag, yet..

rclone copy D:\source D:\dest --update -v 
INFO  : 01.txt: Copied (new)
INFO  :

I have to be honest, rereading the OP's post, I am not clear as there are contradictions.

A has new files. A has 1 large new file, but doesn't want to copy.

The flag shared from rsync wouldn't work there either as that skips creating new files which A has, but you want to exclude one specific file.

If you randomly have to exclude something, you would have to use exclude.

If you want to not copy newer files to the remote, update would work.

You'd have to hammer our your exclusion logic a bit to see if a flag fits or doesn't fit.

Hi Animosity022,

Not sure what is unclear.

A, B and Remote are synced.
A makes a bunch of changes to existing files.
A creates a new file.
A copies all changes to Remote.
Remote holds up to date versions of all files, including the new file.
B wants to update all files, it already has, but doesn't care about the new file.

rclone copy remote B, would copy both updated files and any new files. --update is also implied in copy, no?

If I was rsync-ing A to B directly, --existing would update all changed files that are older at the destination but not copy the new file.

Unclear is from my perception as of course it's clear to you :slight_smile:

So you have 3 remotes? A B C ? What is the significance of "Remote?

So this means A copies to C.

Ok

Meaning you want to copy from C->B and ensure B is now in sync?

No update is not implied as normal flow, folks copy from A->B and A updates everything in B and you don't want to skip newer files as that would be a copy.

rclone isn't rsync so it's a bad compare on how things operate as they operate very differently.

Rclone copy/sync is really one way. You have to pick a source of truth and decide what you want to do with changes. If you have a method to exclude them, you can use exclude.

You can skip newer files on the destination or you can overwrite them.

I'd avoid comparing as they operate very different from each other as noted above.

Good post on some applications:

Which. may fit your use case.

There is a feature request out there for 2 way sync as well which might be it but I can't seem to locate the issue offhand.

Hi Animosity022,

So you have 3 remotes? A B C ? What is the significance of "Remote?

Remote signifies that it's actually a cloud service and not another computer.
So as per OP, A and B are two computers and Remote is Google Drive.

So this means A copies to C.

If by copies or syncs you are referring to the specific functionality of rclone copy or rclone sync, no.
A could be using either sync or copy, as it's not removing any files.
It doesn't actually matter what method is used, the point is that stuff changed and those changes are now in the Remote.

No update is not implied as normal flow

Indeed, it seems I've baked --update in my script and then though update was the default behavior.

I'd avoid comparing as they operate very different from each other as noted above.

I'm not comparing the two either. I'm using functionality already existing in one, widely-used application as an example of what I want to do.

There is a feature request out there for 2 way sync as well which might be it but I can't seem to locate the issue offhand.

I'm not sure if two-way sync actually reflects on what I need.
Wouldn't two-way sync also download non-locally-existing files, on B?

In Rclone, there are remotes, remotes can local or a cloud service as there's no difference in how things operate.

Copy makes A identical to B with deleting any extra.
Sync makes A completely identical to B with deleting things on B so it's a mirror copy.

I'm not sure exactly what those two in that respect as I don't use either one and haven't completely read through how they work. Perhaps @jwink3101 might have some ideas and can translate your need a bit better than I can as I'm still unfortunately not quite following the decision tree to for the three remotes and could to decide what gets copied or not.

Hi Animosity022,

Maybe this will help you follow the decision tree :

I have a work computer and a home computer.
I backup "everything" to Google Drive.
The home computer has a copy of all files including, say, my porn folder. It's private and has a big enough hard drive.
I need some of that stuff on the work computer without, say, the porn folder.
If I make a change to my .bashrc on the home computer I want that mirrored to the work computer, but doing an rclone copy --update would also copy the porn folder.

Yes, I can theoretically exclude the porn folder, using --exclude, but in reality it's not a porn folder, it's not even stuff in a specific folder, say archive. It's stuff that must exist in the same folder as other stuff and is not easily filtered with a pattern, say the extension or a filename prefix.

Having used rsync in the past, to similarly "synchronize" from a remote system I knew about the --existing option, and wondered if there's some way to replicate this behavior in rclone.

I can script around this by running rclone check first and building an exclusion filter based on the output, but was wondering if there was a "native" way of doing it.

There is no flag like --existing from rsync in rclone.

Easier to just use A B C for remotes in rclone to describe it as well.

Doesn't matter what a remote is in rclone as a remote can be a local disk, ftp site, cloud provider, etc.

If you have folders you do not want included and you know what they are, you can also use:

https://rclone.org/filtering/#exclude-directory-based-on-a-file

And drop an exclude file in each directory you don't want.

Actually, I think @asdffdsa mentioned this in a different post.

I don't use rsync much but --existing is this right?

            --existing              skip creating new files on receiver

And rclone has:

      --ignore-existing                      Skip all files that exist on destination

I feel that does the same thing re-reading your ask again as my previous statement I think was incorrect.

In rsync, sender is the source and receiver would be the destination which should translate to source destination in rclone so rsync A -> B and rclone copy A: B: with those flags I think would be identical.

You can test with --dry-run and validate as that I think is your answer.

If I'm not mistaken there is currently no such option in rclone. You could however use a two step process:

  1. Check, which files are in source but not in target
  2. Write that difference into a filter list
  3. use this filterlist for the rclone copy

See this example:

md in out
echo 1 > out/1
sleep 2
echo 2 > in/1
echo 3 > in/2
rclone check in out --missing-on-dst skiplist
rclone copy in out --exclude-from skiplist -v

Or you can use that...

If I understood the OP correctly --ignore-existing would just achieve the opposite of what was intended: OP does want to update files that are in the target, and only these, not the ones missing from there.

Have to let the OP answer then as his rsync flag is identical to the rclone flag I shared so if that's the case, something doesn't make sense.

If that is the case, they could script this pretty easily.

$ rclone lsf A: > filters.txt
$ rclone copy --files-from-raw filters.txt remote: A:

files-from-raw says it can directly read lsf output.

This isn't the most efficient since it has to list A: twice but assuming it is local, that is fast and not a problem

Animosity022, not sure why you still think that what I want is to exclude existing files (on the destination), when the actual need is the opposite and, I believe, has been adequately described.

@brdlgwmpft thanks, yes, I've already thought of that but wanted to see if there's a built-in solution, either with a specific flag or some kind of built-in filter.

Because that's what you said right here:

felix@gemini:~$ rsync --existing /home/felix/test/ /home/felix/test1/ -P -av
sending incremental file list
./
two
             10 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=0/3)

sent 153 bytes  received 38 bytes  382.00 bytes/sec
total size is 10  speedup is 0.05
felix@gemini:~$ cat test1/two
update me
felix@gemini:~$ ls test
one  two
felix@gemini:~$ ls test1
two

That excludes or skips creating new files on the receiver side.

Godspeed.

Yes, Animosity022, that's what I want. To skip creating new files on the receiving end.

So if Remote, or C as you like it, has files :

1.txt, modified today
2.txt, modified today
3.txt, modified today

And computer B, has files :

1.txt, modified yesterday
2.txt, modified yesterday

I'd want to do rclone copy C B --magic-flag-that-doesnt-exist so that in the end, B ends up with :

1.txt, modified today
2.txt, modified today

Again, I'm not sure how you're confused.
@brdlgwmpft and @asdffdsa seem to have gotten it right on the first try.

Clearly, they are just smarter than me.

Again, I'm surprised you continue to talk down to someone spending their time to help you out. Good luck as I'm done.