Skip to main content

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.

Quick Summary

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​

FlagDescription
--dry-run / -nPreview what would be cleaned
--verbose / -vShow what's being removed
--log-file PATHWrite log to file

Backend Support​

Backendcleanup Behavior
Google DriveEmpties trash
OneDriveEmpties recycle bin
DropboxPermanently deletes trashed files
S3Removes old versions (if versioning enabled)
GCSRemoves old versions (if versioning enabled)
BoxEmpties trash
SFTP / LocalNot 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​

weekly-cleanup.sh
#!/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​

PitfallConsequencePrevention
Running on unsupported backendError or no-opCheck backend support table
Not running --dry-run firstPermanently deletes trashed filesAlways preview
Expecting path-level cleanupcleanup usually operates at account levelCheck backend-specific behavior
Cleaning up shared drivesMay affect shared contentBe 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