Short answer: use private object storage with a standard API, keep backup objects under tenant-scoped keys, retain the original receipt, and issue short-lived signed download links only after an authorization check. The cheapest-looking bucket is not the cheapest recovery path if one tenant can read another tenant's archive or a restore cannot be verified.
I care about this because backup jobs fail in boring ways. I've been paged by missed jobs and duplicate deliveries, and the first dashboard often says only that the worker is healthy. A scheduler can run on time and still produce a duplicate delivery, a missing object, or a database row pointing at the wrong tenant. In an edtech system, the object is often a receipt that must survive an audit, while the application also needs a copy of the original file. Storage selection is part of that control path.
One rule helps: the object key is an identifier, never an authorization decision. Keep the bucket private. Authorize the download in the application, then mint a temporary signed URL for the exact object.
It fails quietly.
Tenant isolation is the first restore requirement
Start with a contract that can be tested. For each backup or receipt, store the tenant ID, an application-owned object ID, the original filename as metadata, the content digest, the storage region, and the retention deadline. The key can then be deterministic without exposing a tenant's business name:
backups/{tenant_id}/{object_id}/original
The tenant segment is useful for isolation and cleanup, but it is still only routing information. A guessed key must not be readable. The server must check the caller's tenant membership against the database record before it signs a download.
The US/EU question is a data-governance question before it is a latency question. Pick the allowed region explicitly, record that choice with the backup row, and test restore from the same region. Do not silently let a client choose a bucket or prefix. A browser can upload the file directly to storage, but the backend should create the pending record and the signed upload target. When the nightly worker reports success but the audit record is absent, I want one trace that joins the tenant, backup ID, object key, digest, and retention decision; otherwise an on-call engineer is left comparing timestamps across three systems while the restore window gets shorter.
The original receipt deserves its own lifecycle. A processed image, OCR result, or normalized accounting row can be regenerated; the original may be the evidence an auditor asks for. Retention should therefore be expressed as a policy on the object record, not as an assumption hidden in a UI. If an object is due for deletion, the job needs to know why it is eligible and which tenant policy permitted it.
Keep the state machine small:
-
pending: the application reserved an object ID but has not verified the bytes. -
stored: the upload completed and the server recorded the digest and size. -
expired: the retention policy allows deletion and the record has passed the required checks.
The transition to stored is the important one. A client saying “upload finished” is not enough if the backend never reconciles the expected key and metadata. A periodic reaper handles abandoned pending records; it should be idempotent because the scheduler may deliver the same task twice.
How do signed download links protect tenant isolation during restores?
The download endpoint should accept an application object ID, not an arbitrary storage key. The handler loads the record, checks tenant membership and any receipt-level permission, then asks the storage layer for a signed GET target. The URL should expire soon enough to limit accidental sharing, but not so soon that a legitimate download routinely fails. The exact duration belongs in the threat model and operational tests.
Here is the shape of the decision in Go. The storage client is deliberately an interface, so the authorization boundary does not depend on a particular vendor SDK.
package receipts import ( "context" "errors" ) var ErrNotFound = errors.New("receipt not found") var ErrForbidden = errors.New("receipt is outside the tenant") type Receipt struct { ID string TenantID string ObjectKey string } type ReceiptStore interface { Find(ctx context.Context, receiptID string) (Receipt, error) } type ObjectStore interface { SignedGet(ctx context.Context, key string, ttlSeconds int64) (string, error) } type DownloadService struct { receipts ReceiptStore objects ObjectStore } func (s DownloadService) Link(ctx context.Context, tenantID, receiptID string) (string, error) { receipt, err := s.receipts.Find(ctx, receiptID) if err != nil { return "", ErrNotFound } if receipt.TenantID != tenantID { return "", ErrForbidden } return s.objects.SignedGet(ctx, receipt.ObjectKey, 300) } The five-minute value is an example policy setting, not a universal answer. The important properties are the ownership check, the server-held key, and a bounded authorization artifact. Do not return a permanent public URL as a shortcut. Do not put a storage access key in browser JavaScript. Log the receipt ID, tenant ID, decision, and outcome, while avoiding the signed URL itself; URLs often contain credentials in query parameters.
CORS is a separate browser concern. A signed URL can be valid and still fail in a browser if the storage endpoint does not allow the requesting origin, method, or headers. MDN's CORS guide is a useful reference for the preflight exchange. When the required policy cannot be configured, proxy the bytes through an application endpoint with explicit streaming and connection limits. That costs application capacity, so it should be a conscious boundary rather than an accidental fallback.
How can compatible object storage protect app data backups?
Compare the failure modes first and the price sheet second. For this workload, the questions are: can the team keep a bucket private, can it select the required US or EU location, can the client use a common object-storage workflow, can operators test a restore, and can retention be enforced without deleting the evidence too early? I'm not sure any monthly estimate stays useful without the team's actual restore frequency and retention schedule.
| Approach | Good fit | Trade-off to accept |
|---|---|---|
| Managed S3-compatible object storage | Teams that want a familiar private-object workflow | Policy, region, request, and retention details still need review |
| Self-hosted S3-compatible storage | Teams that own the disks, networking, replication, and on-call burden | The storage bill may be visible, but operations become part of the product |
| Application proxy over private storage | Browser constraints or inspection require a server boundary | Large transfers consume application connections and capacity |
No option wins every row. A self-hosted system is not suitable when the team cannot operate replication and restore drills. A proxy is not suitable when the web tier has no streaming, timeout, or concurrency budget. A storage API with familiar request semantics is not suitable when its retention and regional controls cannot meet the audit policy. Stick with the managed service when the operational burden is the real risk.
The same comparison applies to backup tooling. A small backup can use one request, but a large archive should use multipart upload so a failed part can be retried without restarting the entire object. The multipart protocol has its own cleanup path: an upload that is created but never completed must be aborted or it can leave incomplete work behind. AWS documents the multipart upload lifecycle and its completion requirements; the protocol is portable as a design idea even when the storage endpoint is not AWS.
Do a restore drill before selecting a winner. Create a test object for two tenants, attempt a cross-tenant read, expire a signed link, interrupt an upload, retry the completion task, and restore the original bytes. The expected result is more valuable than a benchmark performed against an empty bucket.
Implement the backup state transition as an idempotent operation
The worker should generate a stable backup ID before it touches storage. It writes a pending record with the tenant ID and retention policy, uploads to the derived key, verifies completion, and then performs one idempotent state transition. If the same queue message arrives twice, the second execution should observe the stored record and stop. That is how duplicate deliveries become harmless.
type Backup struct { ID string TenantID string ObjectKey string Status string } type BackupRepository interface { CreatePending(ctx context.Context, tenantID, backupID, key string) error MarkStored(ctx context.Context, backupID string, size int64, digest string) error Get(ctx context.Context, backupID string) (Backup, error) } type Uploader interface { Put(ctx context.Context, key string, data []byte) (size int64, digest string, err error) } func StoreBackup(ctx context.Context, repo BackupRepository, upload Uploader, tenantID, backupID string, data []byte) error { key := "backups/" + tenantID + "/" + backupID + "/original" if err := repo.CreatePending(ctx, tenantID, backupID, key); err != nil { return err } if existing, err := repo.Get(ctx, backupID); err == nil && existing.Status == "stored" { return nil } size, digest, err := upload.Put(ctx, key, data) if err != nil { return err } return repo.MarkStored(ctx, backupID, size, digest) } Real implementations should stream rather than hold a large backup in memory, and they should make the repository transition conditional on the expected state. The example leaves those transport details behind the interfaces on purpose. The invariant is the part worth carrying into a runbook: the database never claims a verified object before the upload completes.
Observe both sides of the boundary. Count pending age, completion latency, signed-link denials, cross-tenant authorization failures, aborts, and restore success. Alert on old pending objects and missing scheduled backups, not just on worker process health. A green scheduler with no stored artifacts is a red incident.
The right choice is the least complex private storage path that satisfies region, retention, isolation, and restore requirements. Price matters. It just does not outrank a recoverable audit trail.
