rclone Cleanup
rclone cleanup removes backend-specific trash, temporary files, and old file versions. Many cloud providers keep deleted files in a trash/recycle bin that still consumes your storage quota — cleanup empties that trash.
Think of cleanup as "empty the recycle bin" for your cloud storage. It's backend-dependent — some providers support it, others don't. After running cleanup, deleted files are permanently gone.
Basic Syntax
rclone cleanup REMOTE: [flags]
# Clean up trash on Google Drive
rclone cleanup gdrive:
# Clean up trash on OneDrive
rclone cleanup onedrive:
# Dry run — see what would be cleaned
rclone cleanup gdrive: --dry-run -v
Key Flags
| Flag | Description |
|---|---|
--dry-run / -n | Preview what would be cleaned |
--verbose / -v | Show what's being removed |
--log-file PATH | Write log to file |
Backend Support
| Backend | cleanup Behavior |
|---|---|
| Google Drive | Empties trash |
| OneDrive | Empties recycle bin |
| Dropbox | Permanently deletes trashed files |
| S3 | Removes old versions (if versioning enabled) |
| GCS | Removes old versions (if versioning enabled) |
| Box | Empties trash |
| SFTP / Local | Not applicable |
Practical Examples
Empty Google Drive Trash
# Check what's in trash first
rclone cleanup gdrive: --dry-run -v
# Clean up
rclone cleanup gdrive: -v
Reclaim Storage After Bulk Delete
# Step 1: Delete old backups
rclone delete gdrive:old-backups -v
# Step 2: Files are now in trash — empty it
rclone cleanup gdrive: -v
# Step 3: Verify reclaimed space
rclone about gdrive:
S3 Version Cleanup
# Remove old object versions (versioned bucket)
rclone cleanup backup-s3:my-versioned-bucket -v
Scheduled Cleanup
#!/bin/bash
LOG="/var/log/rclone/cleanup-$(date +%Y-%m-%d).log"
for remote in gdrive: onedrive:; do
echo "Cleaning ${remote}" >> "$LOG"
rclone cleanup "${remote}" --log-file "$LOG" --log-level INFO -v
done
Common Pitfalls
| Pitfall | Consequence | Prevention |
|---|---|---|
| Running on unsupported backend | Error or no-op | Check backend support table |
Not running --dry-run first | Permanently deletes trashed files | Always preview |
| Expecting path-level cleanup | cleanup usually operates at account level | Check backend-specific behavior |
| Cleaning up shared drives | May affect shared content | Be cautious with team/shared storage |
What's Next
Examples with Output
1. Empty Google Drive Trash
Permanently remove all items currently in your Drive's trash. Command:
rclone cleanup gdrive:
Output:
(Google Drive trash is emptied; space is reclaimed)
2. Clean up OneDrive Recycle Bin
Clear out deleted items to free up account storage. Command:
rclone cleanup onedrive:
Output:
(OneDrive recycle bin emptied)
3. Remove old S3 object versions
Clean up non-current versions in a versioned S3 bucket to save costs. Command:
rclone cleanup s3-backup:my-versioned-bucket -v
Output:
2024/01/15 12:00:00 INFO : data.zip: Deleted 5 old versions
4. Dry run of trash cleanup
Safely check if the backend supports cleanup before executing. Command:
rclone cleanup remote: --dry-run
Output:
2024/01/15 12:00:00 NOTICE: Trash cleanup would remove 150 items (dry run)
5. Check storage after cleanup
Verify how much space was recovered. Command:
rclone cleanup gdrive: && rclone about gdrive:
Output:
Total: 15 GiB
Used: 5.2 GiB (was 5.5 GiB)
Free: 9.8 GiB