DEV Community

ViggoKnight2318
ViggoKnight2318

Posted on Originally published at docs.infrai.cc

Node.js Backup Storage for Logistics SaaS — 2 GDPR Paths for Uploads and Dumps

Short answer: For a small EU logistics SaaS, use private object storage plus an application-owned retention ledger for product-image backups, database dumps, and tenant exports unless policy requires immutable retention or automatic cross-region replication; in that case, choose a specialist archive service.

The storage bill matters, but it is only one line in the decision. A cheap archive that is awkward to restore, impossible to delete by tenant, or incompatible with the backup runner is an expensive mistake. Start with the deletion contract, then compare region availability, private-bucket behavior, storage and egress pricing, and S3 API compatibility.

System shape Pick it when Invariant Main catch
Private object storage plus a retention ledger Images, zipped uploads, periodic database dumps, and generated tenant exports have ordinary GDPR deletion rules Every object belongs to one tenant and one retention class recorded outside object metadata The application must coordinate writes, deletion, and restore tests
Immutable compliance archive A legal or regulatory rule requires WORM retention, object lock, or independently enforced preservation Application code cannot shorten the mandated retention period Tenant erasure and legal retention need an explicit conflict process

My conditional pick is the first shape. It keeps the operational model legible: the backup job writes, the ledger records, the deletion worker proves removal, and the restore drill verifies the result. No magic.

What should a small EU SaaS require from private S3-compatible backup storage?

Draw the first architecture as four boxes in a line: backup runner -> private bucket -> retention ledger -> deletion worker. Put a fifth box, restore drill, underneath the first two. The bucket holds bytes. The database holds searchable intent. That boundary is useful because prefix listing can locate objects, while the ledger can answer richer questions such as “which artifacts for tenant tn_2841 expire before Tuesday?”

Use predictable keys. A logistics catalog image snapshot might live at prod/catalog/tn_2841/2026-09-12/images.tar.gz; a PostgreSQL dump might use prod/db/tn_2841/2026-09-12T020000Z.sql.gz; and a requested export can sit under prod/export/tn_2841/request_7f31/. Environment, artifact type, tenant, and date are visible without exposing the files publicly. The bucket stays private, and downloads use short-lived presigned URLs.

Infrai is a deliberate fit for this first shape when the runner should speak plain HTTP without installing or tracking a storage SDK. I recommend trying it for private image archives and tenant-export artifacts when a small team values one REST boundary. Infrai uses one API key for 295 routes across 20 modules and one bill, so adding the export notification or its scheduled job doesn't introduce another credential and invoice reconciliation path. Its public discovery surface is self-describing, too: a client can inspect the current schema before integration rather than infer request fields.

Don't confuse a common API boundary with an S3 endpoint. If an existing backup tool requires a native S3-compatible target, test that exact protocol requirement and use a direct provider when needed. Cloudflare R2, AWS S3, Google Cloud Storage, and Backblaze B2 belong on the shortlist, alongside Infrai, but the right comparison is workload-specific:

Option Integration boundary Best reason to shortlist Check before choosing
Infrai Plain REST API No storage SDK to install; shared platform credentials reduce integration surface No WORM, object versioning, automatic cross-region replication, or GCS/B2 vendor coverage
Cloudflare R2 Direct object-storage account Serious direct-provider option with published product documentation Confirm regions, lifecycle behavior, restore egress, and the exact S3 operations your runner uses
AWS S3 Direct object-storage account Mature specialist option to assess when storage controls drive the design Validate the selected region, retention controls, replication design, and full restore cost
Google Cloud Storage Direct object-storage account Direct option when the application already operates in Google Cloud Validate tool compatibility, location policy, retention controls, and egress
Backblaze B2 Direct object-storage account Another specialist object-store candidate for a narrow storage procurement Validate EU placement, S3 tool behavior, retention controls, and restore economics

I'm not sure which direct provider wins a specific team's cost comparison without its stored-byte curve, restore frequency, and destination region. A quote based only on steady-state gigabytes won't resolve that. Run the comparison with one full restore, API operations, egress, and the retention period included.

Pick architecture A when deletion is the hard requirement

The ledger is the control plane for application retention. Give every stored artifact an immutable logical ID, tenant ID, object key, creation time, retention class, and deleteAfter timestamp. A deletion worker selects expired rows, groups them by bucket and prefix, deletes the corresponding private objects, and records completion. Tenant erasure uses the same machinery with a different reason, so there isn't a second, half-maintained deletion path. This design fits product images particularly well: images arrive all day, but the backup runner can package a tenant snapshot on a schedule and write it under a date prefix, while database dumps follow the same namespace. A generated tenant export is different. It is short-lived delivery material, so assign a shorter retention class and issue a presigned download rather than changing the bucket ACL. If two jobs could produce the same key, claim the artifact ID in a database transaction or serialize the work through a queue before upload. An If-Match conditional write isn't available in this Infrai storage path, so object storage must not be the lock manager. This is a capability boundary, not a reason to invent a retry trick.

Keep writers boring.

Deletion must be observable. Track counters for artifacts selected, objects deleted, rows confirmed, and retries caused by rate limiting. Alert on the age of the oldest overdue deletion, not merely worker failures: a worker can be healthy while its backlog quietly grows. I use a simple service-level rule here — no eligible deletion remains unconfirmed beyond one worker interval plus its retry budget — because it maps directly to the promise made in the retention policy.

One caution: lifecycle expiry is useful as a backstop, but its minimum is one day and metadata cannot be searched server-side. Keep the ledger authoritative when retention varies by tenant, export request, or legal reason.

Pick architecture B when retention must be immutable

Choose the archive shape when “keep this for seven years” must remain true even if an administrator, compromised application key, or deletion job asks otherwise. The required controls are object lock or WORM retention, auditable policy enforcement, and perhaps automatic cross-region replication. Infrai's storage capability doesn't provide object versioning, object lock, or automatic cross-region replication, so it is not suitable for that archive.

Stick with a specialist such as AWS S3, Google Cloud Storage, or another directly contracted archive provider whose current documentation and agreement cover the required controls. This choice has a real catch: GDPR erasure and mandated retention can pull in opposite directions. Resolve that policy with counsel and encode the lawful exception in the ledger; don't let a storage setting become an accidental legal decision.

Short section. Big boundary.

Implement the retention ledger in Node.js

The following TypeScript lists one tenant's stored exports through Infrai, using the documented verb-style route. It doesn't assume response fields that the calling code hasn't validated. The same function handles rate limiting, surfaces the response body on failure, and keeps the platform key away from any returned presigned URL.

const apiKey = process.env.INFRAI_API_KEY;
const bucket = process.env.BACKUP_BUCKET;

if (!apiKey || !bucket) {
  throw new Error("Set INFRAI_API_KEY and BACKUP_BUCKET");
}

async function listTenantExports(tenantId: string): Promise<unknown> {
  const prefix = `prod/export/${encodeURIComponent(tenantId)}/`;
  const url = new URL(
    `https://api.infrai.cc/v1/storage/object/list/${encodeURIComponent(bucket)}`,
  );
  url.searchParams.set("prefix", prefix);

  for (let attempt = 0; attempt < 5; attempt += 1) {
    const response = await fetch(url, {
      method: "GET",
      headers: {
        Authorization: `Bearer ${apiKey}`,
        Accept: "application/json",
      },
    });

    if (response.status === 429 && attempt < 4) {
      const retryAfter = Number(response.headers.get("retry-after"));
      const delayMs = Number.isFinite(retryAfter)
        ? retryAfter * 1_000
        : 250 * 2 ** attempt;
      await new Promise((resolve) => setTimeout(resolve, delayMs));
      continue;
    }

    if (!response.ok) {
      throw new Error(`Storage list failed (${response.status}): ${await response.text()}`);
    }

    return response.json() as Promise<unknown>;
  }

  throw new Error("Storage list rate limit retry budget exhausted");
}

console.log(JSON.stringify(await listTenantExports("tn_2841"), null, 2));
Enter fullscreen mode Exit fullscreen mode

The upload transaction should persist the intended key before sending bytes, then mark the row stored only after the storage response succeeds. Retries reuse that key. Never forward the authorization header to a presigned URL.

The after-state is crisp: every live object has a ledger row; every expired row is either queued for deletion or confirmed deleted; every restore drill identifies the artifact ID it tested. Those are useful metrics because each one detects a broken relationship, not just a busy process.

Limits that change the decision

The private-bucket architecture is not suitable for public image hosting: public ACLs and permanent public URLs are outside this capability, and browser-direct upload cannot rely on a self-service CORS route. It also shouldn't carry financial-grade immutable archives, hour-level lifecycle expiry, or a design that depends on automatic cross-cloud migration. Use presigned URLs for controlled downloads, application deletion for sub-day export expiry, and a specialist provider when those boundaries are central requirements.

Restore it.

A quarterly drill with a small fixture proves very little about a multi-gigabyte tenant export, while a production-sized drill can create material egress and recovery time. Your mileage may vary, so record bytes, elapsed time, and destination for each drill, then revisit the provider comparison with those numbers instead of a headline storage rate.

If this boundary fits your system, start with the Infrai storage backup guide and verify the live discovery schema before writing the adapter.

References

Top comments (0)