When conducting rclone sync, a new file version is created if the local file is different than the existing file on the cloud. I would like to sync without creating a new file version; that is, I would like to completely remove the old existing file on the cloud.
There may be two possible approaches, but neither works well:
Delete old versions of the files after syncing. However, rclone cleanup doesn't accomplish this for GoogleDrive - it only empties the trash. Manually removing all the old versions is inconvenient.
Delete the targeted files on the cloud before syncing. I don't know a good (and automatic) way to do so, other than parsing the output from rclone sync --dry-run.
Any suggestions and thoughts are welcomed
What is your rclone version (output from rclone version)
v1.57.0-beta.5684.8b8a943dd
Which cloud storage system are you using? (eg Google Drive)
GoogleDrive
The command you were trying to run (eg rclone copy /tmp remote:tmp)
Thanks. Because multiple versions of a file count toward the storage. Due to my account setting (part of an education account), the versions are kept permanently unless I manually delete them. I am not the organization admin and cannot change the setting, hence the ask.
I was just wondering if there is any other approach beyond what I had written in the main post. What you said is what I had known, which is bad news
Seems like a sensible idea. I don't see an obvious way to implement it though other than reading the revisions list and deleting the old revisions after a successful upload which would take quite a few transactions.
BTW this should be possible with --delete-before
--delete-before When synchronizing, delete files on destination before transferring
Thanks Nick for the tip on --delete-before. But it doesn't seem to solve my user case - maybe I'm doing something wrong. I find it only deleting the files that no longer exist on the source directory. If a file exists on both source and destination and if the two don't match, --delete-before won't delete the file from destination; it still uploads on top of the file and makes a new version. What I was hoping is to delete (before syncing) not only the files that no longer exist on the source side, but also those files that need update. In other words, I was hoping to delete every file that doesn't match the source and then do a clean re-upload.
I thought delete before is for deleting files not in the destination and it does that before the sync starts as opposed to after so I don't think it fits for your use case.
You could use rclone check --differ to find files which are present on both sides and then feed that into rclone delete to remove them before you sync, something like this