What is the problem you are having with rclone?
I want to keep the latest two backups of proxmox
Run the command 'rclone version' and share the full output of the command.
root@rclone:~# rclone version
rclone v1.69.3
- os/version: ubuntu 22.04 (64 bit)
- os/kernel: 6.8.12-9-pve (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.24.3
- go/linking: static
- go/tags: none
Which cloud storage system are you using? (eg Google Drive)
Mega
[proxmox-backups-mega]
type = mega
user = XXX
pass = XXX
Script
#!/bin/bash
# Proxmox backup script with rotation - keeps latest 2 backups
LOG_FILE="/var/log/rclone_backup.log"
LOCAL_DIR="/mnt/proxmox-backups"
REMOTE="proxmox-backups-mega:proxmox-backups"
echo "$(date): Starting backup process" >> "$LOG_FILE"
# Sync current backups
echo "$(date): Syncing backups to remote" >> "$LOG_FILE"
rclone sync "$LOCAL_DIR" "$REMOTE" -P >> "$LOG_FILE" 2>&1
if [ $? -eq 0 ]; then
echo "$(date): Sync completed successfully" >> "$LOG_FILE"
# Get list of files sorted by modification time (newest first)
echo "$(date): Cleaning up old backups, keeping latest 2" >> "$LOG_FILE"
# List files, sort by date, skip first 2, delete the rest
rclone lsf "$REMOTE" --format pt | sort -k2 -r | tail -n +3 | while read file; do
filename=$(echo "$file" | awk '{print $1}')
echo "$(date): Deleting old backup: $filename" >> "$LOG_FILE"
rclone delete "$REMOTE/$filename" >> "$LOG_FILE" 2>&1
done
echo "$(date): Cleanup completed" >> "$LOG_FILE"
else
echo "$(date): Sync failed, skipping cleanup" >> "$LOG_FILE"
fi
echo "$(date): Backup process finished" >> "$LOG_FILE"
echo "----------------------------------------" >> "$LOG_FILE"