Skip to content

S3 backup status shows 0 bytes for all incremental backups due to missing pagination in list_target_files() #2578

@snrkl

Description

@snrkl

Environment:

  • Mail-in-a-Box v73
  • Ubuntu 22.04
  • S3 target: AWS S3
  • duplicity 3.0.7
  • boto3 1.42.97

Description:

The backup status page starts reporting 0 bytes for all incremental backups when using S3 as the backup target. The backups themselves complete and upload successfully — the size reporting is wrong.

Steps to reproduce:

  1. Configure MIAB with S3 backup target
  2. Allow backups to run until the bucket contains more than 1000 objects
  3. Observe backup status page shows 0 bytes for incremental backups despite files existing in S3 with correct sizes

Suspected root cause:

list_target_files() in management/backup.py seems to call s3.list_objects_v2() without handling pagination:

  • list_objects_v2 returns a maximum of 1000 objects per call.
  • Once a bucket exceeds 1000 objects the response is truncated.
  • The IsTruncated flag and NextContinuationToken don't seem to be checked, so objects beyond the first 1000 are never seen and their sizes are reported as 0.

Secondary impact

should_force_full() uses backup_status() to calculate incremental sizes relative to the last full backup. Because all incremental sizes are reported as 0, the condition to force a new full backup never triggers, resulting in an indefinitely growing incremental chain.

Potential Fix:

management/backup.py, around line 528.

-			response = s3.list_objects_v2(Bucket=bucket, Prefix=path)
-			bucket_objects = response.get('Contents', [])
-			backup_list = [(key['Key'][len(path):], key['Size']) for key in bucket_objects]
+			bucket_objects = []
+			kwargs = {'Bucket': bucket, 'Prefix': path}
+			while True:
+				response = s3.list_objects_v2(**kwargs)
+				bucket_objects.extend(response.get('Contents', []))
+				if response.get('IsTruncated'):
+					kwargs['ContinuationToken'] = response['NextContinuationToken']
+				else:
+					break
+			backup_list = [(key['Key'][len(path):], key['Size']) for key in bucket_objects]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions