Guide
Premium
Intermediate
Real Projects

PostgreSQL Backups and PITR: WAL Archiving, Native Incremental Backups, pgBackRest and Restore Drills

A practical guide to the system that only matters on the day everything goes wrong: why RPO and RTO decide your architecture before any tool does, what pg_dump does and does not do (and the three omissions that ruin a restore: roles, extensions, and the cost of rebuilding indexes), continuous WAL archiving and the merciless contract of archive_command — the command that returns 0 without copying, and the one that fails until pg_wal fills the disk and takes production down — real monitoring with pg_stat_archiver, base backups with pg_basebackup and why --wal-method=stream makes the copy self-contained, the low-level API renamed in PostgreSQL 15 (pg_backup_start/pg_backup_stop, exclusive mode gone), verification with pg_verifybackup and its tar support in PostgreSQL 18, native incremental backups since PostgreSQL 17 with summarize_wal, wal_summary_keep_time and pg_combinebackup, including the indivisible-chain trap that turns six incrementals into unreadable garbage if you delete the full backup they depend on, a complete step-by-step PITR with recovery.signal, recovery_target_time and why recovery_target_action = pause keeps you from cementing the mistake, timelines and the .history files almost nobody archives, pgBackRest 2.59 with an encrypted S3 repository, block-level incremental backup, delta restore and the check command, the 3-2-1-1-0 rule with Object Lock and an IAM policy that stops production from deleting its own backups, and an automated restore drill in Python that checks content — not just that the instance starts — and exports your real RTO as a Prometheus metric. With eight recurring mistakes, a production checklist and an FAQ. Extended edition: server-side versus client-side compression with parallel zstd and measuring real throughput with --target=blackhole, parallel dump and restore and the single-large-table limit, the backup that faithfully copies your corrupted data (checksums on by default in PostgreSQL 18, pg_checksums, online enabling in PostgreSQL 19 and pg_amcheck against the restored copy), finding the exact instant with pg_waldump and recovering by XID or LSN instead of guessing a timestamp, surgical single-table restore with a throwaway instance and explicit SQL reconciliation, the replication slots that fill pg_wal (max_slot_wal_keep_size and PostgreSQL 18's idle_replication_slot_timeout), pg_rewind for bringing the old primary back without copying three terabytes and why it is not a backup, the arithmetic of retention and the repo1-retention-archive trap, repository encryption and the break-glass procedure that breaks the key's circular dependency, managed services and the cross-region or cross-account copies that lose PITR, a full minute-by-minute case study with a real 54-minute RTO, and a glossary.

45 minutes read
Josue Garcia
2 views

Verificando acceso...

Loading comments...

Related Resources

Guía
PREMIUM

API Errors with Problem Details (RFC 9457): One Standard Format, Stable Types, and Clients That Stop Parsing Strings

A practical guide to standardising your API errors with Problem Details (RFC 9457): the anatomy of type, title, status, detail and instance, extension members, validation with multiple errors, centralised FastAPI implementation, a TypeScript client that branches on type, security (what not to reveal), OpenAPI documentation, contract tests, common mistakes and an adoption checklist. With code in Python, TypeScript, YAML and HTTP. Expanded edition of 12 October 2026: the type catalog as a contract (stable URIs, about:blank, the IANA registry and evolution rules), a problem registry in code that generates the docs, domain exceptions and a central FastAPI handler with headers and localization, a robust TypeScript client with retries, Retry-After and jitter, per-type metrics and alerts, migrating without breaking clients, Spring, ASP.NET and Node, async errors, batches and idempotency, a case study, FAQ and glossary. Expansion of October 16, 2026: the boundaries almost nobody covers: errors generated by gateways and proxies (nginx and Envoy local_reply_config), a client that survives intermediary HTML responses, errors in the middle of an SSE or NDJSON stream with a terminal frame and resume cursor, partial failures in batches, disciplined design of extension members with extra="forbid", linting with Spectral, fuzzing with Schemathesis, client tests with MSW and a runbook for spikes in one problem type.

Guía
PREMIUM

API Versioning and Contract Testing: Safe Changes, OpenAPI in CI, Pact, and Retiring Endpoints with Sunset

A practical guide to changing your APIs without breaking the people who consume them: why compatibility rules invert between the request and the response —and why widening a returned enum breaks clients even though you are "only adding"—, the tolerant reader pattern in Pydantic with an escape hatch and a metric, OpenAPI generated from the code and diffed on every pull request with oasdiff (including the git diff --exit-code step without which the whole check is theatre), consumer-driven contract testing with Pact: type matchers instead of literal values, well-designed provider states, version selection with deployed_or_released, and the gate that actually makes it safe, can-i-deploy paired with record-deployment. It also covers rolling this out without stopping the factory using pending and WIP pacts, bi-directional contracts when the provider is a third party, the three versioning strategies with their real operational costs, why versioning the whole API for a single endpoint guarantees nobody migrates, retiring versions with the Deprecation (RFC 9745) and Sunset (RFC 8594) headers plus the migration Link, the per-consumer metric without which no sunset date is ever met, brownouts returning 410 Gone before the final shutdown, and the BACKWARD, FORWARD and FULL compatibility modes for event schemas. With production-ready code in Python, YAML, Bash and PromQL, eight recurring mistakes, a production checklist, FAQ and glossary. It also extends the contract beyond the happy path: errors with RFC 9457 (problem+json), cursor pagination and defaults as part of the contract, the expand/contract pattern for renaming a field across database and API with no maintenance window, governance with Spectral, buf breaking for gRPC and Protobuf, GraphQL schema evolution with @deprecated and real per-field usage, and semantic versioning of generated SDKs. It also covers the contracts that never show up in the schema and break just as hard: outbound webhooks with the version pinned on the subscription, HMAC signing with a timestamp window and key rotation, Idempotency-Key for safe POST retries, the RateLimit and RateLimit-Policy headers —and why lowering a limit is a breaking change—, and OAuth scopes, the blind spot no OpenAPI diff will ever catch.

Guía
PREMIUM

Architecture Decision Records (ADRs): Document the Why Behind Your Technical Decisions

A practical guide to recording architecture decisions with ADRs: what they are and are not, when to write one, a template covering context, alternatives and consequences, a lifecycle with statuses and supersession, and automation with a creation script and a CI validator. With Bash, Python and YAML code, common mistakes and a checklist. Expanded edition of October 2, 2026: writing context with evidence, alternatives without straw men and a weighted decision matrix with sensitivity analysis, Nygard, MADR 4 and Y-statement templates, the advice process with roles, CODEOWNERS and a PR template, the boundary between ADRs, RFCs, design docs and runbooks, ADRs as executable architecture with import-linter and fitness tests, generated index and supersession graph, scheduled reviews with Review-by, two complete annotated ADRs, ADRs at scale in monorepos and multi-repo setups, adoption through retroactive ADRs, ADRs as context for coding assistants, health metrics, advanced mistakes, FAQ and glossary.