Sync with delete files only older than some time

What is the problem you are having with rclone?

Hi all!
I want to perform sync between source and destination with this condition: remove from destination only files, which not present on the source and older than 1 month.
For example:
Source files: [A, B, C]
Destination files before sync: [A, B, C, D, E] (file D created 10 days ago, file E created 100 days ago)
Destination files after sync: [A, B, C, D]
What rclone command/options can do it?

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

rclone v1.61.1
- os/version: ubuntu 20.04 (64 bit)
- os/kernel: 5.4.0-146-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.19.4
- go/linking: static
- go/tags: none

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

DigitalOcean Spaces

The rclone config contents with secrets removed.

[bkp_dev]
type = s3
provider = DigitalOcean
access_key_id = ***
secret_access_key = ***
endpoint = sfo3.digitaloceanspaces.com
acl = private

[dev]
type = s3
provider = DigitalOcean
access_key_id = ***
secret_access_key = ***
endpoint = nyc3.digitaloceanspaces.com
acl = private

welcome to the forum,

this would create a list of files missing on the source and feed that to rclone delete

rclone check source: dest: --missing-on-src=./missing.txt --max-age=30d
rclone delete --files-from=missing.txt --dry-run -vv

maybe there is a way to use a single command.
i have never tested this flag, not 100% sure how it works and any side effects.
rclone sync source: dest: --delete-excluded --max-age=30d --dry-run -vv

Thank you for help!
This magic works:

rclone check dev:storage/test/src bkp_dev:storage/test/dst --config /etc/rclone.conf --missing-on-src=./missing.txt --min-age=30d
rclone delete bkp_dev:storage/test/dst --config /etc/rclone.conf --dry-run -vv --files-from=missing.txt

This command

rclone delete --files-from=missing.txt --max-age=30d --dry-run -vv

not works because

Failed to load filters: the usage of --files-from overrides all other filters, it should be used alone or with --files-from-raw

And this

rclone sync source: dest: --delete-excluded --max-age=30d --dry-run -vv

also not works, perhaps because filtering applied only to source, not destination.
Thank you! Issue is closed!

i had not tested those commands, as they were just quick suggestions.
good that you could test them and find the combo that worked for you.

1 Like

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