Encrypted recovery in private R2: a separate reader and CLI restoration
Private R2 for encrypted captures: separate writer and reader, atomic uploads, exact hash verification and 27-file restoration through the CLI.
An encrypted copy on a laptop still depends on the laptop itself. As the next practical step, I moved a capture into a separate private R2 bucket, downloaded it with another key and verified decryption through the CLI. This run used an actual capture from a separate Debian VM. This separate VM experiment extends the file-recovery exercise. I kept primary E-01 backups in the Mirohost panel; R2 is not a required step in setting up this VPS.
Separate permissions for provisioning, writing and reading
The operator's manager creates new credentials, a temporary R2 administrator creates one new bucket, a writer stores capture objects, and a reader only reads them. For the latter two keys, I verified exactly one bucket resource and a finite lifetime. R2 can scope Object Read/Write permissions to a specific bucket.
The private request template follows. Set the access expiry explicitly in RFC3339; it is a value for the particular fixture, not the date of the article's practical work. All paths are absolute, and credential files must be new.
{
"bucket": "example-lab-recovery",
"other_bucket": "existing-bucket-for-isolation-check",
"name_prefix": "example-lab-recovery",
"expires_on": "<REVIEWED_RFC3339_EXPIRY>",
"writer_file": "/ABSOLUTE/PRIVATE/recovery-writer.env",
"reader_file": "/ABSOLUTE/PRIVATE/recovery-reader.env"
}
Planning checks the manager and selectable permissions. After reviewing the private plan, pass its exact SHA256 to create. The temporary administrator expires one hour after planning. That is a finite lifetime, not a claim of immediate token revocation.
deploy-cli cloudflare recovery-bucket plan \
--env-file "$R2_MANAGER_PROFILE" \
--request-file "$RECOVERY_REQUEST" \
--plan-file "$BUCKET_PLAN"
deploy-cli cloudflare recovery-bucket create \
--env-file "$R2_MANAGER_PROFILE" \
--plan-file "$BUCKET_PLAN" \
--plan-sha256 "$BUCKET_PLAN_SHA256" \
--approve-write
Verify credentials before installing profiles
The native run confirmed disabled r2.dev access and an empty custom-domain list. Both keys received 200 for their own bucket and 403 for another existing bucket. The writer created a test object and both keys read its exact bytes; the reader's attempt to create a new object received 403.
A repeated writer PUT with If-None-Match: * returned 412. After the checks, the CLI deleted only its own test object and confirmed both test keys absent. Only then did it install the two private profiles. Working objects in other buckets remained unchanged.
Bind capture names to their bytes
The lower capture already has an accepted metadata SHA256, an encrypted CMS hash and a public recipient hash. The new storage plan accepts that exact pair and independently pinned writer/reader profiles.
deploy-cli cloudflare recovery-object plan \
--account "$R2_ACCOUNT" --bucket "$RECOVERY_BUCKET" \
--writer-file "$WRITER_PROFILE" --writer-sha256 "$WRITER_SHA256" \
--reader-file "$READER_PROFILE" --reader-sha256 "$READER_SHA256" \
--capture-file "$CAPTURE_METADATA" --capture-sha256 "$CAPTURE_SHA256" \
--ciphertext-file "$CAPTURE_CMS" \
--plan-file "$OBJECT_PLAN"
The two object keys derive from the metadata digest. The private decryption key belongs neither in those objects nor in the upload parameters.
captures/<CAPTURE_METADATA_SHA256>/application-recovery.cms
captures/<CAPTURE_METADATA_SHA256>/capture.json
deploy-cli cloudflare recovery-object upload \
--plan-file "$OBJECT_PLAN" \
--plan-sha256 "$OBJECT_PLAN_SHA256" \
--approve-write
Before writing, the CLI persists a separate intent, performs two atomic creates, then reads both objects with the separate reader. Hashes and sizes must match. A lost response or incomplete pair stops without an automatic retry. In the native run, uploading the completed pair again also refused before another write.
Download first, decrypt separately
Download uses the retained plan, upload completion and reader. It does not access the original local capture files or writer. The new directory receives only verified encrypted bytes.
deploy-cli cloudflare recovery-object verify \
--plan-file "$OBJECT_PLAN" --plan-sha256 "$OBJECT_PLAN_SHA256"
deploy-cli cloudflare recovery-object download \
--plan-file "$OBJECT_PLAN" --plan-sha256 "$OBJECT_PLAN_SHA256" \
--target-directory "$DOWNLOADED_CAPTURE" --approve-write
The existing local restore then receives the key only on the laptop. All variables in this example identify private local files; the metadata SHA is independently accepted from the initial capture output, and the OpenSSL binary is pinned by digest as well.
deploy-cli host application recovery-restore \
--capture-file "$DOWNLOADED_CAPTURE/capture.json" \
--capture-receipt-sha256 "$CAPTURE_SHA256" \
--ciphertext-file "$DOWNLOADED_CAPTURE/application-recovery.cms" \
--recipient-file "$PUBLIC_RECIPIENT" \
--private-key-file "$LOCAL_RECOVERY_KEY" \
--openssl-sha256 "$LOCAL_OPENSSL_SHA256" \
--target-directory "$NEW_RESTORE_DIRECTORY"
All 27 files were restored and verified. Accepted modes and xattrs were preserved inside a private directory; original ownership was not applied and no services started. This run verified file restoration; application startup and database restoration require their own steps. After verification, I removed the local plaintext drill directory and retained the encrypted R2 copy.
The frame below summarizes saved actual results, without executing the commands again.
The experiment boundary and key custody
The key was not sent to the VM or Cloudflare. Independent recovery of encrypted files needs an available private key: losing the only copy would make CMS decryption impossible. This separate VM experiment does not verify provider backups. Their freshness and restoration through the Mirohost panel need their own evidence, rather than an R2 upload time. Selecting a location for an additional RSA-key copy is not a prerequisite for continuing E-01 setup.