I'm trying to use rclone for backuping my database file. I need to copy it (only one file) to my Google Drive once a day (I've added a cron task for it). And I also add copy datetime to file name in a storage. But I want to keep only last 10 backups. Howto setup this behavior?
Run the command 'rclone version' and share the full output of the command.
rclone v1.68.0
os/version: ubuntu 24.04 (64 bit)
os/kernel: 6.8.0-44-generic (x86_64)
os/type: linux
os/arch: amd64
go/version: go1.23.1
go/linking: static
go/tags: none
Which cloud storage system are you using? (eg Google Drive)
Google Drive
The command you were trying to run (eg rclone copy /tmp remote:tmp)
tho, not a perfect solution as it deletes by date, not by count, assumes the cron job never fails. rclone delete gdrive:MySite --min-age=10d --dry-run -vv
a safer version might be this. then manually prune as needed. rclone move gdrive:MySite gdrive:MySite_archive --min-age=10d --dry-run -vv
a more complete solution to would be something like.
rclone lsf gdrive:MySite > all_files.txt to list all the files in the folder.
process all_files.txt, to create a subset of files to be deleted called delete_files.txt
Thank you, but that is not working for me.
In my storage have 1 file that was created early this morning (rclone lsf gdrive:MySite outputs 2024.09.16_03:00:01_data.db/). I've tried to delete files that were created more that 1 hour ago but command rclone delete gdrive:MySite --min-age=1h -vv doesn't delete any file. Isn't a problem that I rename my file when create a backup copy (data.db -> 2024.09.16_03:00:01_data.db)?
Even rclone lsl gdrive:MySite -vv (without --min-age=1h) displays no files, while rclone lsf gdrive:MySite displays my file (2024.09.16_03:00:01_data.db/).
As you see every day I copy my file with a new name (via rclone copy) and I don't use rclone sync.
Maybe thats why rclone lsl is empty, maybe there is no modtime in this case?
2024/09/16 17:22:19 DEBUG : rclone: Version "v1.68.0" starting with parameters ["rclone" "lsl" "gdrive:MySite" "--min-age=1h" "-vv"]
2024/09/16 17:22:19 DEBUG : Creating backend with remote "gdrive:MySite"
2024/09/16 17:22:19 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2024/09/16 17:22:19 DEBUG : Google drive root 'MySite': 'root_folder_id = root' - save this in the config to speed up startup
2024/09/16 17:22:20 DEBUG : 8 go routines active
2024/09/16 17:24:19 DEBUG : rclone: Version "v1.68.0" starting with parameters ["rclone" "lsf" "gdrive:MySite" "-vv"]
2024/09/16 17:24:19 DEBUG : Creating backend with remote "gdrive:MySite"
2024/09/16 17:24:19 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2024/09/16 17:24:19 DEBUG : Google drive root 'MySite': 'root_folder_id = root' - save this in the config to speed up startup
2024.09.16_03:00:01_data.db/
2024/09/16 17:24:20 DEBUG : 6 go routines active
tl;dr - if you want to rename a file whilst copying it, must use rclone copyto, then would see something like INFO : data.db: Copied (new) to: 2024.09.16_03:00:01_data.db
sorry, not correct. check the debug output of your original copy command. INFO : data.db: Copied (new)
2024.09.16_03:00:01_data.db/
that is a not a file, it is a folder, notice the trailing slash.
note: the destination of rclone copy is always a folder, never a file.
in effect, you asked rclone to create a new folder named 2024.09.16_03:00:01_data.db
Oh, my mistake. I'm newbie to Linux so didn't notice that. Thank you, now after rclone copyto I can see my file with rclone lsl gdrive:MySite. Will check tomorrow (after cron task executes) if --min-age flag is working.
So now rclone lsl gdrive:MySite displays info about my file (created by cron at 03:00): 1712128 2024-07-03 17:55:38.000000000 2024.09.17_03:00:01_data.db.
As I can see --min-age flag is working by local file LastWriteTime (2024-07-03 17:55:38), not LastWriteTime of a file on a remote storage (2024.09.17 03:00:01). Looks like I will need to use that your recommendation:
Is that correct and I cannot make rclone with some flag work by remote file LastWriteTime or name?
And BTW what is the first number (1712128) in rclone lsl command result output?
Many thanks for your help.