Diagram showing abandoned multipart upload chunks hidden from S3 listings and automated cleanup script recovering storage

Every large file uploaded to an S3-compatible bucket goes through a multipart upload. The client splits the file into chunks (typically 5 MB to 100 MB each), uploads them in parallel, and finally tells the storage API to stitch them together into a complete object.

Here is the trap: if the network drops halfway through, or a deployment worker is killed by an out-of-memory killer, those uploaded chunks do not disappear. They sit in your bucket as uncommitted parts. They do not appear in <code>aws s3 ls</code>, but they consume storage and appear on your bill month after month.

The monthly cost of ghost storage

Because incomplete parts are invisible in standard file listings, teams often discover them only after their storage usage creeps upward despite file counts staying flat.

Daily abandoned uploadsAverage sizeGhost storage after 90 daysMonthly waste at $0.020/GBMonthly waste at $0.023/GB (AWS S3)
5 failed backup jobs20 GB9.0 TB$180.00 / mo$207.00 / mo
20 interrupted video uploads2.5 GB4.5 TB$90.00 / mo$103.50 / mo
50 interrupted database dumps8 GB36.0 TB$720.00 / mo$828.00 / mo
100 worker crashes (small batches)500 MB4.5 TB$90.00 / mo$103.50 / mo

How to inspect incomplete uploads from the CLI

To see what is currently lingering in your bucket, standard <code>list-objects</code> will not work. You must use the low-level <code>list-multipart-uploads</code> API command:

bash
aws s3api list-multipart-uploads \
  --bucket my-backups \
  --endpoint-url https://s3.tport.space

If any uploads were abandoned, the response returns a JSON structure listing the file key, the initiation timestamp, and the unique <code>UploadId</code>:

json
{
  "Uploads": [
    {
      "UploadId": "2~x9Ak82pLq019Z...",
      "Key": "postgres-daily-2026-11-01.sql.gz",
      "Initiated": "2026-11-01T02:14:22.000Z",
      "StorageClass": "STANDARD",
      "Owner": {"DisplayName": "tps-usr", "ID": "usr-1042"}
    }
  ]
}

To inspect the exact parts and bytes held by that upload id:

bash
aws s3api list-parts \
  --bucket my-backups \
  --key postgres-daily-2026-11-01.sql.gz \
  --upload-id "2~x9Ak82pLq019Z..." \
  --endpoint-url https://s3.tport.space

A tested Python script to clean up abandoned parts

While AWS S3 offers native S3 Lifecycle rules to abort uploads after N days, many S3-compatible providers, private minio setups, and edge gateways do not support or trigger lifecycle policies automatically. This lightweight Python script audits any bucket and aborts uploads older than your chosen threshold:

python
#!/usr/bin/env python3
"""Purge incomplete multipart uploads older than N days from any S3 bucket."""
import argparse
import sys
from datetime import datetime, timezone, timedelta
import boto3

def abort_old_uploads(bucket: str, max_age_days: int, endpoint: str, dry_run: bool = False):
    s3 = boto3.client('s3', endpoint_url=endpoint)
    cutoff = datetime.now(timezone.utc) - timedelta(days=max_age_days)
    
    paginator = s3.get_paginator('list_multipart_uploads')
    aborted_count = 0
    reclaimed_bytes = 0
    
    print(f"Scanning bucket '{bucket}' for uploads older than {cutoff.isoformat()}...")
    for page in paginator.paginate(Bucket=bucket):
        uploads = page.get('Uploads', [])
        for u in uploads:
            initiated = u['Initiated']
            if initiated < cutoff:
                key = u['Key']
                uid = u['UploadId']
                age_days = (datetime.now(timezone.utc) - initiated).days
                
                # Sum up parts size
                parts_resp = s3.list_parts(Bucket=bucket, Key=key, UploadId=uid)
                upload_bytes = sum(p['Size'] for p in parts_resp.get('Parts', []))
                reclaimed_bytes += upload_bytes
                
                if dry_run:
                    print(f"[DRY RUN] Would abort: {key} ({upload_bytes / (1024**2):.1f} MB, {age_days}d old)")
                else:
                    s3.abort_multipart_upload(Bucket=bucket, Key=key, UploadId=uid)
                    print(f"Aborted: {key} ({upload_bytes / (1024**2):.1f} MB, {age_days}d old)")
                aborted_count += 1
                
    action = "Would abort" if dry_run else "Aborted"
    print(f"Done: {action} {aborted_count} uploads, recovering {reclaimed_bytes / (1024**3):.2f} GB.")

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description="Audit and abort abandoned S3 multipart uploads.")
    parser.add_argument("bucket", help="Name of the S3 bucket")
    parser.add_argument("--days", type=int, default=3, help="Max age in days before aborting (default: 3)")
    parser.add_argument("--endpoint", default="https://s3.tport.space", help="S3 endpoint URL")
    parser.add_argument("--dry-run", action="store_true", help="List without aborting")
    args = parser.parse_args()
    
    abort_old_uploads(args.bucket, args.days, args.endpoint, args.dry_run)

Best practices for production pipelines

  • Run a weekly audit cron: Add the audit script to a weekly cron job. Setting --days 3 provides plenty of runway for legitimate 24-hour uploads to complete while purging stale clutter.
  • Catch client interruptions: In custom Node.js, Python, or Go upload scripts, always hook into process signals (SIGTERM, SIGINT). If an upload loop is cancelled by the user, call abort_multipart_upload immediately before exiting.
  • Tune your part sizes: Avoid tiny 5 MB part sizes on multi-gigabyte files. Larger parts mean fewer HTTP requests and fewer stranded chunks if a connection resets. See our analysis on [multipart upload part sizes for 5 GB, 50 GB and 500 GB files](https://tport.space/articles/multipart-upload-part-size-5gb-50gb-500gb) for benchmarked thresholds.