Update --backup-dir modification times

What is the problem you are having with rclone?

I'm using Google Drive (crypted) as my backup destination and I'm trying to set up some kind of simple retention policy.
My goal is to delete removed files after a certain time from the --backup-dir location (30 days for example).

However when I run the delete command with --dry-run it wants to delete the test.txt file before the retention time is up, if for example I delete it today and run the delete command the file would be removed.
Is there a way to make the --backup-dir also modify the file time in the archive folder to prevent this from happening?

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

rclone v1.58.0

  • os/version: freebsd 12.2-release-p6 (64 bit)
  • os/kernel: 12.2-release-p6 (amd64)
  • os/type: freebsd
  • os/arch: amd64
  • go/version: go1.17.8
  • go/linking: static
  • go/tags: none

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

Google Drive with crypt.

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

Backup command:
rclone sync local_folder gdrive:backup --copy-links --fast-list --backup-dir gdrive:archive

Delete command:
rclone delete --min-age 30d gdrive:archive

hello and welcome to the forum,

for debugging, please post a debug output.
and if possible to keep the output short, try to delete a single file.
rclone delete gdrive:archive/path/to/test.txt --min-age 30d --dry-run -vv

and with --backup-dir, i run a command similar to this, forever forward incremental backups.
will create a new subfolder with date/timestamp.

rclone sync /home/user01/source remote:full --backup-dir=remote:incrementals/`date +%Y%m%d.%I%M%S` -vv

Thank you for your reply. Here's the output, I removed the start part of Creating backend messages.

2022/05/09 18:07:25 DEBUG : --min-age 1M to 2022-04-09 18:07:25.543029033 +0300 EEST m=-2591999.812246144
2022/05/09 18:07:25 DEBUG : rclone: Version "v1.58.0" starting with parameters ["rclone" "delete" "gdrive:/archive" "--min-age" "30d" "--dry-run" "-vv"]
2022/05/09 18:07:30 DEBUG : Waiting for deletions to finish
2022/05/09 18:07:32 NOTICE: test.txt: Skipped delete as --dry-run is set (size 16.653Mi)
2022/05/09 18:07:32 DEBUG : 1 go routines active

and what is the timestamp for test.txt?
rclone lsl gdrive:archive/path/to/test.txt

and for testing, instead of rclone delete,
safer to rclone lsl --min-age=30d -vv

Thanks, here's the output.
The timestamp is in the --backup-dir is the same as the original.

17461918 2022-05-08 11:53:55.877000000 test.txt

The min-age won’t work for what you want because of the times. The best bet is really to script it.

I wrote one but it is only lightly tested. syncrclone/rclone-dated-delete at master · Jwink3101/syncrclone · GitHub

Thank you all for your help. I managed to make a small script to do the thing.

This loops over any older than set days folders and removes them from the remote. Assumes date format YYYY-MM-DD and BSD.

#/!bin/bash
days=30
for i in `rclone lsd gdrive:/archive | cut -c 44- | egrep '^[0-9]{4}-[0-9]{2}-[0-9]{2}$' | sort | awk -v date="$(date -v-$days'd' '+%Y-%m-%d')" ' $0 < date '`; do
  rclone purge gdrive:/archive/$i --dry-run -vv;
done

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