Delete files not on source only (don't copy new/changed files)

With sync, I know that rclone can behave similarly to rsync, so copy new/modified files on source to destination, and delete extraneous files.

Is it possible to only compare source to destination, by checksum, and only delete files not on source, without copying new files?

I also know the check --one-way command, that does the check, but (AFAIK) doesn't delete.

I've also looked at delete command, but found nothing...

My goal is to compare two S3 buckets, and delete on the destination bucket files not present (or not equal) on the source bucket.

Thanks.

You can use rclone check to make a list of files which are on the destination but not the source like this

rclone check --missing-on-src files.txt s3:source s3:destination

You can then feed this into rclone delete

rclone delete --files-from files.txt s3:destination

Test first with --dry-run!

There might be a combination of sync flags which does this, but they elude me at the moment!

1 Like

Hi Nick, thanks for your reply.

If i understand it correctly, it will check "files which are on the destination but not the source" but it will not check "files which are on the destination but not the source or MD5 != files on the source", correct ? :thinking:

That is correct

Thats

  --missing-on-dst string   Report all files missing from the destination to this file

(note you can use the same filename to send the output of multiple of these flags to the same file)

That is

  --differ string           Report all non-matching files to this file

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