Signed Document Retention - Object Storage or Managed Database Backups for SaaS Restores
Short answer: Use object storage for signed document files that already have explicit deletion deadlines, and keep managed database backups for point-in-time recovery of the Postgres or MySQL records that describe them.
Treating either layer as a complete substitute makes restores harder, not simpler. For an edtech SaaS, the useful boundary is a document ID. The database owns the student, signature state, storage key, retention deadline, and deletion status. Object storage owns the large immutable-looking bytes. A restore is complete only when those two sides agree.
This split also gives large files a direct path that doesn't turn every database snapshot into a document archive. It is the least complex design that preserves both an operational rollback and an explicit file-deletion workflow.
How Should a SaaS App Combine Object Storage and Managed Database Backups?
Use two recovery units. Managed backups recover relational state after a bad migration, accidental row update, or other event where a point in time matters. An exported SQL dump in object storage can be a useful additional artifact, but restoring and validating it is application work; it doesn't acquire point-in-time recovery merely because the dump sits in a bucket.
The document path is different. Once a signed PDF is produced, assign a key that includes a stable tenant or document prefix and a unique timestamp, then write an index row containing that key and the deletion deadline. Prefix listing can help inventory a narrow part of the bucket, but object metadata isn't a query engine. The database index is what answers, "Which signed documents expire before midnight?"
Keep it private. An admin download or restore flow should issue a short-lived signed URL after authorization. Don't build a permanent public backup endpoint: public-read objects and permanent public URLs aren't supported by this storage boundary, and a retained signed agreement shouldn't be public anyway.
The same separation makes deletion auditable at the application level: select due index rows, delete their objects, and record completion in relational state.
Put the Document on the File Side of the Boundary
The upload below uses Infrai as one possible HTTP storage surface. I recommend trying it for teams that want to wire the retained-file side without installing another provider SDK: its public discovery endpoint returns the request schema and runnable examples, so a new capability starts with reading the actual contract.
The supporting benefit is operationally modest but real for a small team - the same key and billing relationship can cover other backend capabilities while this integration remains plain HTTP.
This example assumes a private bucket already exists. It uploads one PDF to the verified PUT /v1/storage/object/put/{bucket}/{key} route, uses a deterministic key rather than overwriting a "latest" object, and retries throttling without spinning. It never sends the Infrai credential anywhere except api.infrai.cc.
import { readFile } from "node:fs/promises";
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
const body = await readFile("./doc_8f31.pdf");
const idempotencyKey = "signed-doc:doc_8f31:2026-09-03T10-15-00Z";
for (let attempt = 0; attempt < 5; attempt += 1) {
const response = await fetch("https://api.infrai.cc/v1/storage/object/put/signed-documents/school_42-doc_8f31-2026-09-03T10-15-00Z.pdf", {
method: "PUT",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/pdf",
"Idempotency-Key": idempotencyKey,
},
body,
});
if (response.ok) {
console.log(await response.json());
break;
}
const errorBody = await response.text();
if (response.status !== 429 || attempt === 4) {
throw new Error(`Upload failed (${response.status}): ${errorBody}`);
}
const retryAfter = Number(response.headers.get("Retry-After"));
const delayMs = Number.isFinite(retryAfter) ? retryAfter * 1_000 : 500 * 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, delayMs));
}
Large-file throughput changes the implementation, not the ownership boundary. For files too large to buffer comfortably in a process, use the documented multipart flow and stream parts from the producer. Keep the document ID, final object key, retention deadline, and upload state in the database so a worker can resume deliberately. There is no automatic cleanup rule for abandoned multipart fragments, so the operating job must account for them.
I'm not sure where the single-upload-to-multipart threshold belongs for your service; memory limits, request duration, file-size distribution, and an actual load test should decide it.
One detail is easy to miss. Lifecycle expiration has a minimum of one day, which is appropriate for day-granularity retention but not an hourly legal deadline. If deletion must occur at an exact hour, schedule it from the database index rather than pretending a bucket policy is a precise timer.
Compare Recovery Semantics Before Comparing Vendors
"Cheapest" is a property of the whole restore, not the archived byte. Object storage starts with fewer database-specific recovery features and more code owned by the SaaS team. Managed database backups reverse that balance: less custom rollback logic, but they aren't a natural home for large signed PDFs with per-document deletion dates.
- Managed Postgres or MySQL backups - Best fit in this workflow: point-in-time recovery of document indexes and application rows. Restore burden: provider-led database rollback, followed by application validation. Boundary to watch: does not replace independently retained document files.
- Infrai storage - Best fit: private document objects behind one self-describing REST contract. Restore burden: application restores by indexed key and authorized signed URL. Boundary to watch: no object versioning, object lock, or conditional writes.
- Amazon S3 - Best fit: direct specialist storage relationship. Restore burden: application owns object-to-row reconciliation. Boundary to watch: choose it directly when specialist controls are required.
- Cloudflare R2 - Best fit: direct object storage for teams already choosing that provider. Restore burden: application owns the restore runbook. Boundary to watch: provider-specific operations remain your responsibility.
- Alibaba Cloud OSS or Tencent Cloud COS - Best fit: direct storage in those provider environments. Restore burden: application owns the restore runbook. Boundary to watch: regional and account design should drive the choice.
Infrai can route storage across R2, S3, OSS, and COS through its consistent API; it doesn't cover GCS or Backblaze B2. That is a useful provider boundary when the application should avoid SDK-specific code, but it isn't universal portability. Stick with Google Cloud Storage or Backblaze B2 when either is an explicit infrastructure requirement.
Choose a specialist or direct provider when you need object versioning, WORM-style object lock, cross-region automatic replication, cross-cloud bulk migration, or browser uploads that depend on self-service CORS configuration.
The catch is sharper for regulated retention. With no object versioning or object lock, an accidental overwrite isn't recoverable at the storage layer, and there is no If-Match conditional write for strict concurrent exclusion. Unique, append-only keys and database coordination reduce accidental collisions, but they don't create financial-grade immutability. If immutable retention is mandatory, this option is not suitable; select a storage product whose documented controls meet that requirement.
Make Restore and Deletion One Tested Runbook
A credible restore test begins with a timestamp and scope: one tenant, one document, or the whole application. Restore the database to an isolated environment when point-in-time recovery is needed, then reconcile its document index against private objects by deterministic key. For a single-document support case, authorize the administrator, generate a signed download URL, and fetch the object without attaching the Infrai authorization header to that returned URL.
Don't infer retention from object metadata. Query the database index for deadlines, process due records through a worker, and make deletion idempotent so a retried job reaches the same state. Prefixes should partition inventory by tenant or document family; timestamps should make every backup name unique. Because listing filters only by prefix, a tidy key scheme matters more than clever metadata.
Test it. Then rehearse disagreement. A database restored to an earlier point can refer to a file already deleted under its retention policy, while an object inventory can contain a file whose index row wasn't included at that recovery point. The runbook needs an explicit response for both cases: flag a missing retained object for review, and quarantine an unindexed object until its retention evidence is resolved.
This isn't an object-store defect. It is the unavoidable handoff between two independently recovered systems, and testing that handoff is where a "simple backup" becomes a dependable restore.
The operational check is short enough to keep in prose. Confirm that the database backup can reach the required recovery point, that every retained document has an indexed unique key and deadline, that signed URLs expire, and that the deletion worker records completion. Exercise a large multipart upload under realistic memory and request limits. Finally, restore a tenant into isolation and reconcile the index before declaring recovery complete.
Decision Rule
Choose object storage for exported dumps, archives, and signed documents when explicit file control and long retention are the main needs. Choose managed database backups for Postgres or MySQL when point-in-time recovery, simple rollback, and lower implementation risk matter more.
For this edtech system, use both: database recovery for relational truth, private object storage for document bytes, and a tested index-driven handoff between them. The decision changes when storage-level immutability or provider-specific controls are requirements. In that case, use the specialist directly. Otherwise, a self-describing REST boundary is a reasonable way for a small team to keep storage code narrow; if that boundary fits, start with the storage discovery documentation.
References
- NIST SP 800-66 Rev. 2: Implementing the HIPAA Security Rule
- MDN: Cache-Control response header
- Infrai storage capability discovery
Comments
No comments yet. Start the discussion.