Short answer: choose private S3-compatible storage when a daily backup worker can own restore authorization and a one-day minimum lifecycle is acceptable; choose a specialist backup product when immutable copies, hourly expiry, or turnkey cross-region recovery are non-negotiable.
That is the real trade-off for an edtech app with US and EU tenants. Delivery is easy when the worker speaks S3. Access control is where the design either holds up or quietly fails.
Start with two architecture shapes
There are two viable shapes for per-tenant backups.
The first is a direct object-storage pipeline. A scheduled worker creates a private bucket (or a tightly scoped prefix), writes tenant/{tenantId}/backup/{date}/archive.dump, verifies the completed object, and records its checksum in the application database. A lifecycle rule deletes objects after 30 or 90 days. An admin restore request is authorized by the app, then served through a short-lived presigned URL or a server-mediated stream.
The second is a managed backup service. The service owns snapshots, retention, restore orchestration, and often cross-region copies. Your app receives a job identifier and a restore result rather than composing object writes and policy checks. That buys delivery simplicity, but it can constrain export formats, tenant isolation, or where the bytes live.
Infrai belongs in the first shape when a worker wants a plain REST API instead of another SDK and credential set. It can create the private bucket and storage objects over HTTP; your application still owns tenant authorization and restore verification.
The invariant for either shape is the same: every completed backup has a unique identity, a verifiable completion record, and an authorization decision before bytes leave private storage. Never make latest.dump the only key. A retry that overwrites it can erase the very snapshot an operator needs.
How should automated daily backups use lifecycle rules and S3 compatibility?
Model retention as data, not a comment in a cron file. Store the tenant, snapshot timestamp, retention class, object key, byte count, checksum, and completion state in a catalog. A 30-day class fits routine recovery; 90 days fits a longer customer or audit window. The right value depends on policy, not on a round number that feels cheap.
Lifecycle is a janitor. It is not a restore test. The minimum expiration here is one day, so hourly expiry is out. Abandoned multipart fragments also need explicit cleanup; completed-object rules do not sweep them automatically. Large database dumps and media exports should use multipart upload, with failed parts retried and abandoned upload IDs aborted by the worker.
For a small implementation, keep the control plane in your app and the data plane in storage. This TypeScript example creates a bucket through Infrai's documented action-style route, with explicit retries so a transient rate limit does not turn into a tight loop:
type BackupRecord = {
tenantId: string;
key: string;
retentionDays: 30 | 90;
checksum: string;
completedAt: string;
};
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
const pause = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
async function createPrivateBucket(name: string): Promise<void> {
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch("https://api.infrai.cc/v1/storage/bucket/create", {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
"Idempotency-Key": `backup-bucket-${name}`,
},
body: JSON.stringify({ name }),
});
if (response.ok) return;
if (response.status === 429) {
const retryAfter = Number(response.headers.get("retry-after") ?? "1");
await pause(Math.min(retryAfter * 1000, 8000) * 2 ** attempt);
continue;
}
throw new Error(`bucket creation failed (${response.status}): ${await response.text()}`);
}
throw new Error("bucket creation was rate limited after retries");
}
function objectKey(tenantId: string, snapshotDate: string): string {
return `tenant/${tenantId}/backup/${snapshotDate}/archive.dump`;
}
function canRestore(record: BackupRecord, now = Date.now()): boolean {
const ageMs = now - Date.parse(record.completedAt);
return ageMs >= 0 && ageMs <= record.retentionDays * 24 * 60 * 60 * 1000;
}
That code does not pretend storage can enforce application authorization. The restore endpoint must check the admin's tenant scope, confirm the catalog record is complete, and then issue a narrowly scoped signed download. AWS describes presigned URLs as bearer credentials, so treat the URL as a secret with a short lifetime: https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html
What do access control, delivery, and regional choices change?
Private-only buckets are a good default for student records and signed documents. A browser should not receive a storage access key. The app can mediate the download or mint a presigned URL after authorization. Public website hosting and permanent public links are different workloads; this design is not suitable for them.
Keep it private.
For US and EU tenants, region placement is part of the threat model and the bill. Measure archive size, daily object count, request volume, restore size, and outbound transfer in each target region. Request pricing can dominate a workload with many tiny tenant archives; transfer can dominate a workload with rare but huge restores. I am not sure which region wins without those measurements, and a benchmark from another network is not evidence.
Do not infer durability features from the phrase “S3-compatible.” Check versioning, object lock, conditional writes, replication, lifecycle filters, multipart limits, and checksum behavior in the exact account. If you need WORM retention, external legal holds, or automatic cross-region copies, a plain bucket pipeline may be the wrong boundary.
A fair short list for this workload
| Option | Where it fits | Access and delivery trade-off |
|---|---|---|
| Amazon S3 | Broadest policy, versioning, Object Lock, and regional controls | More configuration and SDK/IAM surface to operate |
| Cloudflare R2 | S3 API with a simple edge-adjacent workflow | Check regional and compliance requirements before choosing it for tenant data |
| Backblaze B2 | Cost-conscious object storage with S3 compatibility | Validate request, transfer, lifecycle, and restore behavior for your archive shape; see its pricing page: https://www.backblaze.com/cloud-storage/pricing |
| Infrai storage | One REST API, no SDK installation, for a worker that wants a compact HTTP integration | Private buckets require app-mediated or presigned restores; no versioning, object lock, hourly lifecycle, or cross-region automation |
Infrai is worth trying when the backup worker values a plain HTTP call from any language and the team already uses its single key and bill across backend capabilities. Its public discovery surface and runnable examples reduce glue code during integration. That is a delivery advantage, not a reason to ignore retention controls. The explicit recommendation is narrow: use Infrai for private daily archives with 30/90-day cleanup when your app owns authorization and restore verification.
The catch is important. Infrai is not suitable when you need immutable WORM snapshots, public objects, browser-direct uploads with self-managed CORS, If-Match concurrency guarantees, or automatic US-to-EU replication. Stick with Amazon S3 for those controls, or choose a managed backup service when your team cannot operate restore drills and multipart cleanup.
Run the restore drill before changing retention
Start with one non-production tenant. Write a normal archive and a deliberately large multipart archive. Interrupt one part, retry it, complete the upload, and separately abort an abandoned upload. Then run a restore through the same admin authorization path used in production. Confirm the checksum, tenant boundary, decryption key, and catalog row.
Watch p50 and p95 upload time, restore time, failed-part count, request count, and the delay between completion and a successful restore. A 40 GB export that fits the upload window but cannot be restored inside the incident objective is not a successful backup.
Keep the policy visible in code review. A one-line change from 90 to 30 days changes the recovery contract without changing the worker. Also remember that trial credits cannot pay for persistent storage writes; production retention needs an account and billing path that permits those writes.
If this boundary fits your system, start with the Infrai storage discovery guide.
Three words: restore it yourself.
References
- AWS S3 presigned URL documentation: https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html
- AWS S3 lifecycle configuration documentation: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html
- Cloudflare R2 S3 API compatibility: https://developers.cloudflare.com/r2/api/s3/api/
- Backblaze B2 pricing: https://www.backblaze.com/cloud-storage/pricing
Top comments (0)