Diagram showing an S3 restore that preserves later writes in the original bucket and recovers the backed-up keys in an empty bucket.

Which Keys Survive an In-Place S3 Restore with AWS Backup?

Fri, Dec 4, 2026

Consider an illustrative recovery ticket: an application owner reports that one S3 object was edited incorrectly and another object appears missing. At the same time, a support team created a legitimate new object after the backup. The recovery lead is therefore not deciding only which recovery point to use. The harder question is which namespace the owner has actually authorized: a merge that preserves later live data, or a historical namespace whose current keys and logical bytes match the backup.

AWS documents a material distinction for an AWS Backup S3 in-place restore. When restoring to the original bucket, AWS Backup does not destructively replace a live object that already has the same key, regardless of its version. A current delete marker, however, is treated as though the object is absent, so restoration may occur. AWS Backup also does not remove extra live keys merely because they were not present in the backup. By default, the latest backed-up object version is restored.

That means the original bucket can legitimately end with historical bytes for one key, later bytes for another, and an extra post-backup key. A separately verified empty, versioned bucket gives you the contrasting experiment: restore the identical recovery point there and test whether the backed-up current namespace and independently authored payload digests are reproduced.

The lab follows AWS documentation reviewed on 4 December 2026. It has not been run in an AWS environment. The results below are expected or illustrative. The lab provides two acceptance contracts and shows how to collect two restore records and two post-restore inventories, reconcile the evidence in a per-key ledger, and choose a destination.

Agree on what the recovery ticket authorizes

A recovery engineer should settle the acceptance rule before starting a restore. Otherwise, a technically successful restore can produce a state that is operationally unacceptable.

For this lab, use two contracts.

Contract M (merged-state recovery). Preserve every currently live key and its current bytes unless AWS Backup needs to materialize a key that is currently absent because of a delete marker. The owner accepts later edits and later additions. The recovery objective is therefore “fill missing backed-up data without rolling back valid current data.”

Let B(k) be the SHA-256 digest of key k in the backup manifest, P(k) the digest immediately before restore, and R(k) the digest after restore. Let LivePre(k) indicate that a current readable object existed before restore, and Backed(k) indicate membership in the backed-up latest-version scope. The acceptance predicate is:

For every in-scope key k:

if LivePre(k):
    R(k) == P(k)

elif Backed(k) and k is hidden by a current delete marker:
    R(k) == B(k)

and every destination-only live key that existed before restore remains live.

That contract aligns with AWS Backup’s documented original-bucket behavior: a live same-key object is not replaced, a current delete marker makes restoration possible, and keys present now but absent from the backup are not deleted.

Contract H (historical-current-namespace recovery). The owner requires the set of current keys in scope to equal the backed-up latest-version set, with each current object’s logical body matching the independently frozen backup manifest. Later edits and destination-only additions are not acceptable in the candidate.

CurrentKeys(destination) == BackedKeys

and for every k in BackedKeys:
    SHA256(GET-current(k)) == B(k)

This is a namespace contract, not an all-version-history reconstruction contract. If you need to reason about how destination-only files behave under a different recovery model, see how incremental archives treat destination-only files; do not import those filesystem semantics into AWS Backup S3 behavior.

Assign an accountable owner to each rule. A data or application owner should approve Contract M when preserving legitimate later writes is required. A recovery or data owner should approve Contract H when the requested product is the historical current namespace.

One destination can pass one contract and fail the other. In this fixture, the original bucket is predicted to pass Contract M and fail Contract H because ledger/edited.txt and ledger/later.txt remain current. The clean candidate is predicted to pass Contract H if the restore job and evidence checks succeed.

Trace one recovery point into two destinations

The experiment uses one source bucket, one completed periodic AWS Backup recovery point, and two restore jobs from that same recovery point.

The source bucket is also the in-place destination:

s3://<LAB_SOURCE_BUCKET>

The comparison destination is a separately verified empty bucket:

s3://<LAB_CANDIDATE_BUCKET>

Both are private general purpose buckets in the same account and Region, with S3 Versioning enabled. AWS Backup supports backup and restore for general purpose S3 buckets, and the restore guide requires versioning on the destination bucket.

For this playbook:

·       current object means the object returned by an ordinary GetObject call without versionId. Amazon S3 documents that an ordinary GET returns the current version; a version-specific GET uses the versionId parameter and different permission semantics.

·       latest backed-up version means the latest version represented for the object in the recovery point under the selected restore scope. AWS Backup restores only the latest version by default; RestoreLatestVersionsUpTo=1 makes that choice explicit.

·       current delete marker means a DeleteMarker record whose IsLatest value is true in version evidence for that exact key.

·       destination-only means currently live in the destination but absent from the backed-up manifest.

Current visibility and version lifetime are different questions. For a developer-focused treatment of conditional key reuse, see how a current delete marker affects key reuse. This lab does not perform conditional uploads.

The recovery point is an input snapshot. The destination remains a live versioned namespace whose pre-existing state matters. That distinction is exactly why a named recovery point does not, by itself, define the final contents of the original bucket.

The scope here is intentionally narrow: one full-bucket restore, latest version only, paused writers. Continuous point-in-time recovery, all-version reconstruction, cross-account moves, cross-Region moves, ACL migration, KMS troubleshooting, performance testing and production traffic switching are excluded.

Establish the cost and access boundaries of the drill

Use disposable lab buckets and a lab backup vault. Do not test these semantics against an application bucket whose writers cannot be stopped.

Substitute these identifiers:

export AWS_REGION="us-east-1"
export LAB_SOURCE_BUCKET="replace-with-unique-source-bucket"
export LAB_CANDIDATE_BUCKET="replace-with-unique-candidate-bucket"
export BACKUP_VAULT_NAME="replace-with-lab-vault"
export RESTORE_ROLE_ARN="arn:aws:iam::<ACCOUNT_ID>:role/<LAB_BACKUP_RESTORE_ROLE>"
export RUN_DIR="$PWD/aws-backup-s3-restore-evidence"
mkdir -p "$RUN_DIR"

First record the environment rather than assuming it:

aws --version | tee "$RUN_DIR/aws-version.txt"
python3 --version | tee "$RUN_DIR/python-version.txt"
aws sts get-caller-identity | tee "$RUN_DIR/caller.json"
aws configure get region | tee "$RUN_DIR/configured-region.txt"

Record the AWS CLI and Python versions from your own run in the evidence directory.

Create private buckets using the syntax appropriate to your Region, enable versioning, and verify it:

aws s3api put-bucket-versioning \
  --bucket "$LAB_SOURCE_BUCKET" \
  --versioning-configuration Status=Enabled \
  --region "$AWS_REGION"

aws s3api put-bucket-versioning \
  --bucket "$LAB_CANDIDATE_BUCKET" \
  --versioning-configuration Status=Enabled \
  --region "$AWS_REGION"

aws s3api get-bucket-versioning \
  --bucket "$LAB_SOURCE_BUCKET" \
  --region "$AWS_REGION"

aws s3api get-bucket-versioning \
  --bucket "$LAB_CANDIDATE_BUCKET" \
  --region "$AWS_REGION"

Verify public access protections according to your account controls and keep the buckets private. This playbook uses SSE-S3 for restored objects. The AWS Backup restore guide identifies SSE-S3 as a supported restore encryption choice and says no additional encryption-key parameter is needed for it.

Separate the restore role from the observer identity used to inventory and hash data. The restore role needs the S3 and AWS Backup permissions required by your lab configuration; the observer needs enough S3 permissions to list current keys, list versions and read current or version-specific objects. A current-object GET and a version-specific GET are distinct authorization cases.

Before submitting backup or restore work, verify the account, Region, backup service selection, restore role, vault and budget. Expected billable categories can include S3 requests and retained versions, AWS Backup storage and restore activity according to your account’s pricing terms.

Also inspect the selected vault’s retention and immutability conditions before treating it as disposable. Do not change account-wide backup protections or vault controls merely to make the lab easier to delete.

Capture the backed-up keys while the namespace is quiet

Create exactly three baseline objects with literal UTF-8 payloads and explicit trailing newline bytes:

mkdir -p "$RUN_DIR/authored"

printf 'steady-v1\n' > "$RUN_DIR/authored/steady.txt"
printf 'edited-v1\n' > "$RUN_DIR/authored/edited.txt"
printf 'hidden-v1\n' > "$RUN_DIR/authored/hidden.txt"

aws s3api put-object \
  --bucket "$LAB_SOURCE_BUCKET" \
  --key ledger/steady.txt \
  --body "$RUN_DIR/authored/steady.txt" \
  --server-side-encryption AES256 \
  --region "$AWS_REGION"

aws s3api put-object \
  --bucket "$LAB_SOURCE_BUCKET" \
  --key ledger/edited.txt \
  --body "$RUN_DIR/authored/edited.txt" \
  --server-side-encryption AES256 \
  --region "$AWS_REGION"

aws s3api put-object \
  --bucket "$LAB_SOURCE_BUCKET" \
  --key ledger/hidden.txt \
  --body "$RUN_DIR/authored/hidden.txt" \
  --server-side-encryption AES256 \
  --region "$AWS_REGION"

The approved baseline is:

Key

Literal bytes

Length

SHA-256

ledger/steady.txt

steady-v1\n

10

a262436a91bb23192a88481069ef28d29948c01269d06551a9abdb7c73f59d16

ledger/edited.txt

edited-v1\n

10

cc00154de2b0452768c0f40217d1d2d1f962a338efe40dd0ae0d86926640ea9a

ledger/hidden.txt

hidden-v1\n

10

6507da4554ecd30313d78ac03cabb8c93a53f1c98ebf97fb4a95fb949da0a390

Those digests are deterministic for the literal byte strings shown, including newlines. Verify them locally:

python3 - <<'PY'
from pathlib import Path
import hashlib

for name in ["steady.txt", "edited.txt", "hidden.txt"]:
    data = Path("aws-backup-s3-restore-evidence/authored", name).read_bytes()
    print(name, len(data), hashlib.sha256(data).hexdigest())
PY

Read the uploaded objects back and hash the bodies independently:

for key in ledger/steady.txt ledger/edited.txt ledger/hidden.txt; do
  out="$RUN_DIR/initial-$(basename "$key")"
  aws s3api get-object \
    --bucket "$LAB_SOURCE_BUCKET" \
    --key "$key" \
    --region "$AWS_REGION" \
    "$out" > "$out.metadata.json"

  python3 - "$key" "$out" <<'PY'
import hashlib, pathlib, sys
key, path = sys.argv[1:]
data = pathlib.Path(path).read_bytes()
print(key, len(data), hashlib.sha256(data).hexdigest())
PY
done

AWS Backup can back up object metadata including a source version ID, but restoration does not preserve the original creation date, original version ID, storage class or ETag. That makes the source version ID useful evidence about what was backed up but unsuitable as a required target identifier.

Freeze an independent manifest before starting the backup

Capture exact current version IDs before the periodic backup begins:

aws s3api list-object-versions \
  --bucket "$LAB_SOURCE_BUCKET" \
  --prefix ledger/ \
  --region "$AWS_REGION" \
  > "$RUN_DIR/source-versions-before-backup.json"

Record the three IsLatest=true data versions for exact key matches in a manifest kept outside both buckets:

{
  "scope": "latest-version-only",
  "keys": {
    "ledger/steady.txt": {
      "bytes": 10,
      "sha256": "a262436a91bb23192a88481069ef28d29948c01269d06551a9abdb7c73f59d16",
      "sourceVersionId": "<record-from-list-object-versions>"
    },
    "ledger/edited.txt": {
      "bytes": 10,
      "sha256": "cc00154de2b0452768c0f40217d1d2d1f962a338efe40dd0ae0d86926640ea9a",
      "sourceVersionId": "<record-from-list-object-versions>"
    },
    "ledger/hidden.txt": {
      "bytes": 10,
      "sha256": "6507da4554ecd30313d78ac03cabb8c93a53f1c98ebf97fb4a95fb949da0a390",
      "sourceVersionId": "<record-from-list-object-versions>"
    }
  }
}

Now allow the configured periodic AWS Backup plan to run while these three objects remain unchanged. Do not substitute an on-demand recovery point if your purpose is to reproduce this exact fixture.

After the periodic backup reports completion, record:

source bucket ARN
backup job ID
backup vault ARN
completed recovery-point ARN
backup completion time

Export the selected recovery point:

export RECOVERY_POINT_ARN="arn:aws:backup:<region>:<account>:recovery-point:<id>"

The frozen manifest must predate the restore and come from independently authored bytes plus source evidence. A manifest generated from the restored bucket cannot establish what the expected recovery product was.

Create the destination conditions after backup completion

With the recovery point complete, change only the source bucket.

Leave ledger/steady.txt untouched.

Replace ledger/edited.txt with a different 10-byte payload:

printf 'edited-v2\n' > "$RUN_DIR/authored/edited-post-backup.txt"

aws s3api put-object \
  --bucket "$LAB_SOURCE_BUCKET" \
  --key ledger/edited.txt \
  --body "$RUN_DIR/authored/edited-post-backup.txt" \
  --server-side-encryption AES256 \
  --region "$AWS_REGION"

Its digest is:

a5e15c79d08b93ccd8121ac578dac2ae706158fc200357f50426600726e5fa65

Delete ledger/hidden.txt once, creating a current delete marker in a versioning-enabled bucket:

aws s3api delete-object \
  --bucket "$LAB_SOURCE_BUCKET" \
  --key ledger/hidden.txt \
  --region "$AWS_REGION" \
  > "$RUN_DIR/delete-hidden.json"

Create a destination-only post-backup object:

printf 'later-v1\n' > "$RUN_DIR/authored/later.txt"

aws s3api put-object \
  --bucket "$LAB_SOURCE_BUCKET" \
  --key ledger/later.txt \
  --body "$RUN_DIR/authored/later.txt" \
  --server-side-encryption AES256 \
  --region "$AWS_REGION"

later-v1\n is 9 bytes and has SHA-256:

f969d9d866f143030019632ca43f91f98bf02525f8224b3ae21290dbd58c6253

The expected pre-restore current state is:

Key

Pre-restore current state

ledger/steady.txt

readable, baseline digest

ledger/edited.txt

readable, post-backup digest

ledger/hidden.txt

hidden by current delete marker

ledger/later.txt

readable, post-backup destination-only digest

Pause every other writer now and keep writers paused across both restore trials and evidence capture.

Verify the candidate bucket contains neither current objects nor historical versions or delete markers:

aws s3api list-objects-v2 \
  --bucket "$LAB_CANDIDATE_BUCKET" \
  --region "$AWS_REGION" \
  > "$RUN_DIR/candidate-pre-current.json"

aws s3api list-object-versions \
  --bucket "$LAB_CANDIDATE_BUCKET" \
  --region "$AWS_REGION" \
  > "$RUN_DIR/candidate-pre-versions.json"

Do not accept “zero current objects” alone as proof of an unused versioned destination. Inspect both Versions and DeleteMarkers.

Distinguish the marker from an unreadable object

For ledger/hidden.txt, establish two independent facts.

First, attempt an ordinary current GET:

aws s3api get-object \
  --bucket "$LAB_SOURCE_BUCKET" \
  --key ledger/hidden.txt \
  --region "$AWS_REGION" \
  "$RUN_DIR/hidden-pre-current.bin" \
  > "$RUN_DIR/hidden-pre-get.json" 2> "$RUN_DIR/hidden-pre-get.err" || true

A failed GET is not enough to conclude “current delete marker.” S3 documents that the response to a missing current object can differ between 404 Not Found and 403 Access Denied depending on whether the caller has s3:ListBucket.

Second, capture the version listing:

aws s3api list-object-versions \
  --bucket "$LAB_SOURCE_BUCKET" \
  --prefix ledger/hidden.txt \
  --region "$AWS_REGION" \
  > "$RUN_DIR/hidden-pre-versions.json"

Require an exact Key == "ledger/hidden.txt" match and a DeleteMarkers entry with IsLatest == true. ListObjectVersions returns data-version and delete-marker records, and a truncated version listing must be continued with both NextKeyMarker and NextVersionIdMarker.

If the list is incomplete, the prefix is wrong, or the observer receives an authorization error, the precondition is unresolved. Do not remove the marker. Manual marker removal is a different recovery technique; see manually recovering a version hidden by delete markers.

Restore the recovery point to its original bucket

Build the first restore request explicitly:

export ORIGINAL_RESTORE_TOKEN="s3-lab-original-20261204-001"

cat > "$RUN_DIR/restore-original.json" <<EOF
{
  "RecoveryPointArn": "$RECOVERY_POINT_ARN",
  "IamRoleArn": "$RESTORE_ROLE_ARN",
  "IdempotencyToken": "$ORIGINAL_RESTORE_TOKEN",
  "ResourceType": "S3",
  "Metadata": {
    "DestinationBucketName": "$LAB_SOURCE_BUCKET",
    "RestoreACLs": "false",
    "EncryptionType": "SSE-S3",
    "RestoreLatestVersionsUpTo": "1"
  }
}
EOF

aws backup start-restore-job \
  --cli-input-json "file://$RUN_DIR/restore-original.json" \
  --region "$AWS_REGION" \
  | tee "$RUN_DIR/restore-original-receipt.json"

For S3, DestinationBucketName is mandatory restore metadata. RestoreACLs, EncryptionType and RestoreLatestVersionsUpTo are supported metadata fields; setting the latter to 1 requests only the latest version.

StartRestoreJob accepts the recovery-point ARN, IAM role ARN, idempotency token, metadata map and resource type; a successful call returns a RestoreJobId. Repeating an already successful request with the same idempotency token performs no new action.

Use one token per logical restore job. Reuse that token only for an identical retry where idempotency is intended. A change of destination is a different logical request and therefore gets a different token.

Save the returned job ID:

export ORIGINAL_RESTORE_JOB_ID="<from-restore-original-receipt>"

This operation is designed to address ledger/hidden.txt because its current delete marker makes the object eligible for restoration, while the current live ledger/edited.txt is protected by the documented non-destructive same-key rule.

Predict the four outcomes before inspecting the result

Write the prediction down before reading the destination:

Key

Backup state

Pre-restore original state

Predicted original-bucket result

steady.txt

steady-v1\n

same bytes, live

same current bytes remain

edited.txt

edited-v1\n

edited-v2\n, live

post-backup bytes survive

hidden.txt

hidden-v1\n

current delete marker

baseline bytes become readable

later.txt

absent

later-v1\n, live

post-backup object remains

These are predictions derived from documented service behavior, not observed results.

For steady.txt, equality after restore is ambiguous: its baseline bytes already existed. A post-restore digest match does not prove that AWS Backup wrote a version.

For edited.txt, the current version was live before restore. AWS states that when restoring the original bucket, it does not place an object over an existing object regardless of version.

For hidden.txt, the current delete marker causes AWS Backup to treat the object as nonexistent for restore eligibility.

For later.txt, AWS Backup does not remove currently present objects simply because they were absent from the backup.

Restore the same recovery point into the empty bucket

Use the identical recovery point and version policy. Change only the destination-specific values and the idempotency token:

export CANDIDATE_RESTORE_TOKEN="s3-lab-candidate-20261204-001"

cat > "$RUN_DIR/restore-candidate.json" <<EOF
{
  "RecoveryPointArn": "$RECOVERY_POINT_ARN",
  "IamRoleArn": "$RESTORE_ROLE_ARN",
  "IdempotencyToken": "$CANDIDATE_RESTORE_TOKEN",
  "ResourceType": "S3",
  "Metadata": {
    "DestinationBucketName": "$LAB_CANDIDATE_BUCKET",
    "RestoreACLs": "false",
    "EncryptionType": "SSE-S3",
    "RestoreLatestVersionsUpTo": "1"
  }
}
EOF

aws backup start-restore-job \
  --cli-input-json "file://$RUN_DIR/restore-candidate.json" \
  --region "$AWS_REGION" \
  | tee "$RUN_DIR/restore-candidate-receipt.json"

export CANDIDATE_RESTORE_JOB_ID="<from-restore-candidate-receipt>"

AWS requires the selected restore destination bucket to have versioning enabled.

The expected historical candidate is:

Key

Expected membership

Expected logical body

ledger/steady.txt

present

steady-v1\n

ledger/edited.txt

present

edited-v1\n

ledger/hidden.txt

present

hidden-v1\n

ledger/later.txt

absent

No body

That expected set comes from the independent pre-backup manifest, not from the original bucket’s post-backup state.

The diagram traces the same recovery point into the two destination buckets.

Titre : Expected S3 restore outcomes - Description : The periodic recovery point contains steady, edited-v1, and hidden. After backup, edited-v2 is live, hidden has a delete marker, and later is live. Restoring to the original bucket produces the expected merge of steady, edited-v2, hidden-v1, and later. Restoring to the verified empty bucket produces the expected historical set of steady, edited-v1, and hidden-v1.

Use restored bytes as the cross-bucket identity test

Do not require restored version IDs to equal source version IDs. AWS Backup documents the source version ID as backed-up metadata but says the original version ID is among attributes not preserved on restore. The same documentation says original creation date, storage class and ETag are also not restored as the originals.

Instead, identify logical object identity by:

exact key
+ exact byte length
+ SHA-256 computed from independently downloaded GET body

For every present current key:

aws s3api get-object \
  --bucket "$LAB_CANDIDATE_BUCKET" \
  --key ledger/edited.txt \
  --region "$AWS_REGION" \
  "$RUN_DIR/candidate-edited.bin" \
  > "$RUN_DIR/candidate-edited-get.json"

python3 - <<'PY'
from pathlib import Path
import hashlib
p = Path("aws-backup-s3-restore-evidence/candidate-edited.bin")
data = p.read_bytes()
print(len(data), hashlib.sha256(data).hexdigest())
PY

An ordinary GetObject without a versionId tests the current object. Use an explicit versionId only when investigating a specific historical S3 version.

Do not use an ETag as the integrity contract. AWS Backup explicitly does not preserve the original ETag on restore. For a broader treatment of checksum evidence, see the limits of ETags as integrity evidence.

Likewise, an object count is insufficient. Three objects can still include one wrong key or one wrong payload.

Read the job records before opening the buckets

A destination should not be classified until its restore job reaches a terminal state and its status message has been retained.

Poll each job:

aws backup describe-restore-job \
  --restore-job-id "$ORIGINAL_RESTORE_JOB_ID" \
  --region "$AWS_REGION" \
  | tee "$RUN_DIR/describe-original.json"

aws backup describe-restore-job \
  --restore-job-id "$CANDIDATE_RESTORE_JOB_ID" \
  --region "$AWS_REGION" \
  | tee "$RUN_DIR/describe-candidate.json"

DescribeRestoreJob can return the restore job ID, recovery-point ARN, source resource ARN, backup vault ARN, IAM role ARN, resource type, creation date, completion date, status and status message. It also defines fields such as CreatedResourceArn, PercentDone, validation fields and parent-job fields, but the API response schema does not make every one of those fields mandatory evidence for every restore scenario. Treat absent optional fields as absent rather than inventing values.

The documented terminal job states are COMPLETED, ABORTED and FAILED; PENDING and RUNNING are non-terminal.

Record at minimum:

{
  "restoreJobId": "<recorded>",
  "recoveryPointArn": "<must-equal-approved-point>",
  "requestedDestination": "<from-saved-start-request>",
  "status": "<DescribeRestoreJob Status>",
  "statusMessage": "<record verbatim if present>",
  "creationDate": "<if returned>",
  "completionDate": "<if returned>",
  "sourceResourceArn": "<if returned>",
  "backupVaultArn": "<if returned>",
  "createdResourceArn": "<if returned>"
}

Do not equate COMPLETED with “every requested object was restored.” AWS documents a COMPLETED case where one or more, but not all, objects failed to restore. It also documents a COMPLETED case whose message says no objects matched the restore request.

Those documented examples must remain separate from this lab’s expected collision behavior. The existence of a documented partial-restore message does not prove that a preserved same-key object in this fixture would produce that message. The destination must be judged from the actual job message plus object evidence.

If a job fails, diagnose and retain the cause before retrying. Do not silently start another restore and label its evidence as though it came from the first job.

Build a current-key ledger for each destination

Current-key membership begins with a complete ListObjectsV2 traversal. S3 returns at most 1,000 objects per request and exposes IsTruncated plus NextContinuationToken when more results remain.

The safest compact implementation is an SDK paginator:

#!/usr/bin/env python3
import boto3
import hashlib
import json
import sys

bucket = sys.argv[1]
prefix = "ledger/"
region = sys.argv[2]

s3 = boto3.client("s3", region_name=region)
paginator = s3.get_paginator("list_objects_v2")

ledger = []
for page in paginator.paginate(Bucket=bucket, Prefix=prefix):
    for item in page.get("Contents", []):
        key = item["Key"]
        response = s3.get_object(Bucket=bucket, Key=key)
        body = response["Body"].read()
        ledger.append({
            "key": key,
            "bytes": len(body),
            "sha256": hashlib.sha256(body).hexdigest(),
            "versionId": response.get("VersionId"),
        })

print(json.dumps(sorted(ledger, key=lambda x: x["key"]), indent=2))

Run it after both restore jobs are terminal:

python3 inventory.py "$LAB_SOURCE_BUCKET" "$AWS_REGION" \
  > "$RUN_DIR/original-post-current-ledger.json"

python3 inventory.py "$LAB_CANDIDATE_BUCKET" "$AWS_REGION" \
  > "$RUN_DIR/candidate-post-current-ledger.json"

Also retain raw listing pages and post-restore version evidence. For the tiny fixture, the CLI output may fit on one page, but the evidence method must not depend on that accident.

Your compact ledger should include:

Contract

Destination

Key

Expected membership / digest

Observed membership / digest

Pre/post current ID or marker

Disposition

M

original

steady

present / baseline

<observed>

<pre/post evidence>

<pass/hold>

M

original

edited

present / post-backup

<observed>

<pre/post evidence>

<pass/hold>

M

original

hidden

present / baseline

<observed>

marker → <version>

<pass/hold>

M

original

later

present / post-backup

<observed>

<pre/post evidence>

<pass/hold>

H

candidate

steady

present / baseline

<observed>

absent → <version>

<pass/hold>

H

candidate

edited

present / baseline

<observed>

absent → <version>

<pass/hold>

H

candidate

hidden

present / baseline

<observed>

absent → <version>

<pass/hold>

H

candidate

later

absent

<observed>

absent → absent

<pass/hold>

Use UNREADABLE when membership is known but GET fails, and UNKNOWN when permissions or incomplete pagination prevent a reliable conclusion. Never collapse either state into “absent.”

Detect an incomplete inventory before classifying differences

Pagination deserves an explicit negative control because a truncated inventory can create a false historical match.

Synthetic example:

{
  "page1": {
    "IsTruncated": true,
    "NextContinuationToken": "token-page-2",
    "Contents": [
      {"Key": "ledger/edited.txt"},
      {"Key": "ledger/hidden.txt"}
    ]
  },
  "page2": {
    "IsTruncated": false,
    "Contents": [
      {"Key": "ledger/later.txt"},
      {"Key": "ledger/steady.txt"}
    ]
  }
}

A defective collector that reads only page1 falsely omits ledger/later.txt and ledger/steady.txt. S3 explicitly says that IsTruncated=true means more keys are available and the next request must use NextContinuationToken.

A local negative-control check can fail closed:

synthetic = {
    "IsTruncated": True,
    "NextContinuationToken": "token-page-2",
    "Contents": [{"Key": "ledger/edited.txt"}],
}

assert synthetic["IsTruncated"] is True
assert synthetic.get("NextContinuationToken"), \
    "truncated page without continuation token: inventory invalid"

print("NEGATIVE CONTROL: collector must fetch another page")

For version evidence, the rule differs. ListObjectVersions exposes data versions and delete markers, and a truncated result requires both NextKeyMarker and NextVersionIdMarker for the subsequent request.

This is also why shell pipelines that silently select only one CLI page are dangerous. For an adjacent pagination discipline, see checking completeness across AWS CLI result pages.

The sign-off rule is simple: a truncated uncontinued page, ignored permissions error, parser failure or silently discarded unexpected key makes membership unknown. Unknown inventories do not pass either contract.

Explain each leftover and each recovered key

The reconciliation should explain every key, not just report whether the bucket “looks right.”

For ledger/steady.txt, the historical, pre-restore and predicted post-restore bodies are all:

steady-v1\n
SHA256 a262436a91bb23192a88481069ef28d29948c01269d06551a9abdb7c73f59d16

In the original bucket, the bytes were already correct before restore. Equality afterward proves current logical correctness, but not a restore write. To investigate whether a new version appeared, compare pre- and post-restore version evidence. If the current version ID is unchanged, the strongest interpretation is that the live object remained. If it changed, retain the raw evidence before drawing a service-behavior conclusion. AWS Backup’s documented rule says it does not replace an existing original-bucket object, so a runtime observation apparently contradicting that rule would require investigation rather than being normalized away.

For ledger/edited.txt, compare all three byte identities:

State

Bytes

SHA-256

historical manifest

edited-v1\n

cc00154d…ea9a

pre-restore live object

edited-v2\n

a5e15c79…fa65

expected original post-restore

edited-v2\n

a5e15c79…fa65

expected candidate post-restore

edited-v1\n

cc00154d…ea9a

Because the two strings are the same length, a size-only verification would falsely declare both equivalent. This is why the ledger requires an independently calculated digest.

For ledger/hidden.txt, the pre-restore evidence should show a current delete marker plus an older readable data version. AWS Backup documents that a current delete marker is treated as object nonexistence for restoration, so baseline bytes are expected to become current and readable after the original-bucket restore.

Do not require the restored target’s version ID to equal the source version ID; AWS Backup does not preserve the original version ID.

For ledger/later.txt, the source manifest proves it was absent from the recovery point, while pre-restore current evidence proves it was added later. AWS Backup documents that an original-bucket restore does not delete such currently present objects. The clean candidate should therefore omit it because the candidate started empty and the recovery point contains no such key.

The expected reconciled result is:

Key

Original bucket

Clean candidate

Interpretation

steady

baseline

baseline

equality alone cannot prove original-bucket write

edited

post-backup edit

baseline

original preserves collision; candidate reproduces historical bytes

hidden

baseline restored

baseline restored

current marker made key eligible

later

retained

absent

destination-only key survives original restore

In this controlled fixture, the documented rules predict that the live edited object and live later object remain exactly because they are already current data in the original bucket; the hidden object is eligible to be restored; and the already-correct steady object remains correct without equality proving a restore write.

Interpret failed and ambiguous checks

A recovery lead should classify uncertainty before deciding whether to rerun anything.

Condition

Evidence to collect

Immediate interpretation

Next permitted action

Wrong Region or recovery-point ARN

saved request, DescribeRestoreJob, caller/config Region

wrong experiment

stop; submit a new traceable job only after correction

Current inventory truncated

raw pages, continuation tokens

membership unknown

replay inventory; no restore rerun required

Version inventory truncated

raw pages, both next markers

pre/post version state unknown

replay version listing

GET digest mismatch

raw body, GET metadata, exact key, manifest

content failure or wrong expectation

hold; diagnose before rerun

GET returns 403

error body, caller identity, IAM context

unreadable is not absent

correct observation permissions, then reread

Bucket changed during evidence window

timestamps, version IDs, writer logs

experiment contaminated

use a fresh empty candidate if historical qualification is still required

Restore job FAILED

status and status message

restore not qualified

diagnose root cause before new job

Restore job COMPLETED with warning

status message plus object ledger

completion alone insufficient

evaluate every requested object

COMPLETED with no matching objects

status message, request scope

selection may have matched nothing

correct selection or point before retry

The job-message distinction matters because AWS documents both partial-object completion and empty-selection completion as possible COMPLETED outcomes.

If only the inventory was faulty, replaying reads is enough; do not generate a new restore merely to repair your evidence collector.

If the candidate bucket was modified after verification of emptiness, or its provenance is uncertain, use a different verified-empty bucket for a new restore rather than deleting evidence and pretending the original attempt never occurred.

A new bucket or new restore job must receive a new evidence directory and new job identity:

runs/
  attempt-001-original/
  attempt-001-candidate/
  attempt-002-candidate/

Do not overwrite prior raw JSON. Unresolved runtime/documentation discrepancies belong in the sign-off record with the contradictory raw evidence attached.

Decide which destination can advance

Once both ledgers are complete, evaluate each destination against the contract that the owner approved.

Destination

Contract M: preserve later live state, fill missing backup data

Contract H: exact backed-up current namespace and payloads

Routing

Original bucket

Predicted PASS if edited/later remain and hidden returns with baseline bytes

Predicted FAIL because edited is later bytes and later remains

accept merged state only with explicit owner approval

Clean candidate

not the intended merge product

Predicted PASS if exactly steady, edited, hidden match baseline and later is absent

mark LAB QUALIFIED for separate cutover review

Either with incomplete job, inventory or digest evidence

HOLD

HOLD

gather evidence or rerun into a separately verified empty candidate

“LAB QUALIFIED” is deliberately narrower than “production recovery approved.” This exercise does not authorize production traffic switching, deletion, overwrite repair or rollback mechanics.

A practical routing rule is:

1.     Accept merged state when the authorized policy is Contract M, the original-bucket job has an acceptable terminal record, current membership is complete, all expected current digests match, and every exception is approved.

2.     Qualify the clean candidate for separate cutover review when the authorized policy is Contract H and the candidate contains exactly the backed-up current-key set with matching logical bytes.

3.     Hold when the policy is unresolved, the historical and post-backup requirements conflict, the restore record is ambiguous, inventory is incomplete, a digest fails, or destination state changed during the observation window.

A common conflict is “keep ledger/later.txt, but restore ledger/edited.txt to historical bytes.” Neither of these two full-bucket outcomes exactly expresses that hybrid result. The recovery lead should not improvise a purge or selective overwrite. Escalate the key-level conflict to the object or application owner and require a separately authorized recovery plan.

Before any plan touches consumer traffic, it should identify at least the approved destination, exact key scope, accepted manifest or merge policy, treatment of destination-only keys, treatment of post-backup edits, evidence set, accountable data/application owner, execution authority, and rollback or fallback path. Those production mechanics are outside this lab.

Write the recovery owner's sign-off record

Use a record that makes conditional acceptance impossible to mistake for an exact historical recovery:

Recovery ticket:
<ticket-id>

Scope:
s3://<bucket>/ledger/
latest-backed-up-version only

Recovery point ARN:
<arn>

Source bucket:
<name>

Original-bucket restore job ID:
<job-id>

Candidate-bucket restore job ID:
<job-id>

Original restore request evidence:
<private path>

Candidate restore request evidence:
<private path>

DescribeRestoreJob evidence:
<private paths>

Frozen historical manifest:
<private path>

Original post-restore current ledger:
<private path>

Candidate post-restore current ledger:
<private path>

Version evidence:
<private paths>

Approved contract:
[ ] Contract M (merged current state)
[ ] Contract H (historical current namespace)

Selected destination:
<bucket>

Exceptions:
<none or exact keys/findings>

Documentation/runtime discrepancies:
<none or description plus raw evidence path>

Application/data owner:
<name or role>

Recovery lead:
<name or role>

Authorization:
<ticket approval, change record or equivalent>

Classification:
[ ] LAB QUALIFIED
[ ] CONDITIONALLY QUALIFIED
[ ] HOLD

Next permitted action:
<explicitly authorized next action only>

If the original bucket passes Contract M but fails Contract H, the record must say “merged-state recovery accepted,” not “historical recovery successful.”

If the clean candidate matches Contract H, say “candidate LAB QUALIFIED against historical-current-namespace contract.” Do not imply that production cutover was approved.

Preserve the evidence and retire the lab

Keep the independently frozen manifest and the observed destination ledgers under different provenance. The former describes what was expected; the latter describes what was found.

A practical evidence tree is:

aws-backup-s3-restore-evidence/
  aws-version.txt
  python-version.txt
  caller.json
  configured-region.txt
  authored/
  historical-manifest.json
  source-versions-before-backup.json
  backup-job.json
  recovery-point.json
  candidate-pre-current.json
  candidate-pre-versions.json
  hidden-pre-get.err
  hidden-pre-versions.json
  restore-original.json
  restore-original-receipt.json
  describe-original.json
  restore-candidate.json
  restore-candidate-receipt.json
  describe-candidate.json
  original-post-current-pages/
  original-post-versions/
  original-post-current-ledger.json
  candidate-post-current-pages/
  candidate-post-versions/
  candidate-post-current-ledger.json
  signoff.txt

Keep raw evidence private. Published extracts should redact account IDs, bucket names where sensitive, role ARNs, request identifiers and other operational identifiers that are not needed to reproduce the reasoning.

Name an owner for evidence retention and an owner for cloud-resource cleanup. The same person can own both. Record bucket ownership, backup-vault ownership, approved expiry, retained S3 versions, backup retention and any ongoing cost exposure.

Do not clean up the original evidence while an exception is under investigation. If a runtime result appears to contradict AWS documentation, retain the raw request, job description, full S3 listings, version listings, GET metadata and object body digest before changing the bucket.

A second restore is not an “undo” mechanism for an in-place merge. AWS Backup documents that the original-bucket operation is non-destructive toward live same-key objects and destination-only live keys; rerunning a restore therefore should not be treated as a mechanism that rewinds other teams’ later writes.

Cleanup procedures, deletion of retained versions, production cutover and rollback implementation remain outside this playbook.

The operational lesson is narrower and more useful: the recovery point identifies backup input, but the authorized recovery contract defines success. For an AWS Backup S3 in-place restore, current destination state is part of the result. A clean, separately verified destination is how you test the historical-current-namespace alternative without conflating it with a merge.

Practice the cloud operations behind recovery sign-off

This lab exercises the same kinds of cloud infrastructure, access, evidence and monitoring judgments that recovery operators need when they move from “a job completed” to “the requested data state is qualified.” Refonte Learning’s Cloud Engineering Program lists AWS alongside Azure and Google Cloud, cloud infrastructure and networking, Terraform, security, automation and monitoring, with a published three-month duration and 12–14 hours per week commitment. The durable operational takeaway is simpler than any particular tool: the owner approves a named destination, a named acceptance contract, and the specific evidence that proves or disproves it.