Scrivio Interview library
DesignPrincipal6 min read · updated 12 November 2026

Retention rules require keeping database backups for 7 years in some jurisdictions and erasing personal data within 30 days on request in others. As the senior technical leader, how do you reconcile backups, PITR and privacy obligations?

We accept that backups are practically immutable and stop trying to delete records from them; instead we make personal data unreadable there. With crypto-shredding, personal data is encrypted with per-subject or per-tenant keys, and destroying a key erases that person's data everywhere at once, including every backup. We keep long-term compliance archives separate from short-lived PITR backups and minimise personal data in them, document retention and erasure procedures with legal, keep an erasure log that is reapplied after any restore, and test that restoring a backup never resurrects erased data in production.

Background to this question

Two legal obligations seem to collide here. Financial or sector rules in some jurisdictions require records to be kept for years, and privacy laws such as GDPR give people the right to have their personal data erased within about a month. Backups sit at the centre of the collision: they are designed never to change, yet they contain the very data someone has asked us to erase. As senior technical leaders, we have to design a system that satisfies both, in a way we can explain to regulators. In this answer, we will see why editing backups fails, how crypto-shredding solves it, how to separate archives from operational backups, what procedures we agree with legal, and how we test that erasure survives a restore.

1Why We Cannot Just Delete From Backups

A physical PostgreSQL base backup is a copy of data files plus WAL. Removing one person's rows from it would mean restoring it, deleting the rows, and taking a new backup, for every backup that contains them, which for daily backups kept for years means thousands of restores per erasure request. With object lock, the files cannot be changed at all, by design. And the WAL archive would still contain the original inserts, so point-in-time recovery would bring the data back.

Regulators generally understand this. Guidance in several jurisdictions accepts that data in backups can be put beyond use rather than deleted immediately, provided it is not restored into use and is overwritten or expires on schedule. But beyond use must be real, and it must be defensible. Crypto-shredding is the strongest way to make it real.

2Crypto-Shredding: Erasing by Destroying a Key

Crypto-shredding means we encrypt each person's personal data with a key that belongs to that person, or to their tenant in a business product. The keys live in a key service, not in the database. To erase a person, we destroy their key. Every copy of their encrypted data, in production, replicas, every backup and every archive, becomes unreadable at the same moment, without touching any of those copies.

Java
// writing: personal fields are encrypted with the subject's own data key
DataKey key = keys.forSubject(customerId); // created on first use, stored in the key service
customer.setEmailEnc(key.encrypt("ana@example.com")); // ciphertext stored in the database
customer.setNameEnc(key.encrypt("Ana Silva"));
// erasure request
keys.destroy(customerId); // key gone in the key service
keys.forSubjectIfPresent(customerId); // Optional.empty
// every backup still holds the ciphertext, but nobody can decrypt it

Notice what stays in the clear: non-personal data the business must retain, such as the invoice amount, date and tax fields that the seven-year rule actually requires. That split is the design work: which fields are personal and must be shreddable, and which are retained records. The key service itself must be backed up carefully, because losing it by accident would shred everyone; its own backups need short retention so destroyed keys do not linger there for years.

3Separating Long-Term Archives From PITR Backups

The second idea is that not all backups serve the same purpose. Operational backups, the base backups and WAL used for point-in-time recovery, exist to recover from incidents, and a retention of 14 to 35 days is usually enough. The seven-year obligation is about specific records, not about being able to restore the whole database as it was in 2019.

So we keep two separate things. Short-lived PITR backups contain everything, expire quickly and are protected by crypto-shredding for the weeks they exist. Long-term archives are purpose-built extracts of exactly the records the law requires, for example invoices and ledgers, with as little personal data as possible, and with personal fields encrypted per subject as well. That reduces how much personal data lives for years at all.

Two kinds of backup with different rules
PropertyOperational PITR backupsCompliance archive
PurposeRecover from incidentsProve records for 7 years
ContentWhole database plus WALRequired records only
Retention14 to 35 daysAs the law requires
Personal dataPresent, per-subject encryptedMinimised, per-subject encrypted
ErasureExpires within weeks; key shredding meanwhileKey shredding

4Procedures Agreed With Legal

Technology is half of the answer; the other half is a documented procedure that legal and the privacy office have approved. It states which data categories each jurisdiction requires us to keep and for how long, which overrides erasure where retention is a legal obligation, how quickly an erasure request is carried out in production, and how backups are handled, typically by key destruction plus natural expiry of operational backups.

It also covers restores explicitly. We keep an erasure log, a durable record of which subjects were erased and when, holding only an opaque id, not the personal data itself. Any time a backup is restored into use, the procedure requires reapplying every erasure in the log that happened after the backup was taken, before the restored system serves traffic. With crypto-shredding this mostly happens on its own, because the keys are gone, but the log also covers any data that was not encrypted, such as search indexes or legacy tables.

5Testing That a Restore Never Resurrects Erased Data

Finally, we prove it. Restore drills include a privacy check: before the drill, we erase a set of synthetic test subjects; after restoring a backup taken before their erasure, we verify that their personal fields cannot be decrypted and that the erasure log replay removed any remaining traces. If any test subject's email address is readable in the restored copy, the drill fails.

Step throughRestoring a backup without resurrecting erased data
  1. Restore backup into an isolated environmentnot yet serving users
  2. Replay the erasure log since the backup timedelete or blank listed subjects
  3. Run the privacy checkerased test subjects must be unreadable
  4. Any erased subject readable?
    YesStop and fix before go-liveNoAllow the restored system to serve

4 steps in order. Play them, or step through them one at a time.

6Follow-up questions

Does crypto-shredding satisfy GDPR erasure?

It is widely regarded as a strong way to put data beyond use, and many organisations rely on it, but whether it counts as erasure in a given jurisdiction is a legal judgement. That is why the procedure is agreed with legal and the privacy office rather than decided by engineering alone.

What about search indexes, caches and analytics copies?

They need the same treatment. Ideally they store only encrypted personal fields or ids. If not, they must be included in the erasure workflow and the erasure log replay, and short retention helps. A data map of where personal data flows is a prerequisite for any of this.

Does per-subject encryption hurt performance?

It adds a key lookup and decryption per record, which is cheap with cached data keys, but it makes searching on encrypted fields hard. We usually keep a separate blind index, a keyed hash of the email, for lookups, and accept that range queries on personal fields are not possible.

7Conclusion

In this answer, we saw that editing backups is impractical and that crypto-shredding with per-subject or per-tenant keys erases personal data everywhere at once by destroying a key. We separated short-lived PITR backups from minimal long-term compliance archives, documented retention, erasure and restore procedures with legal, kept an erasure log to reapply after any restore, and proved in restore drills that erased data is never resurrected.

What to say in the interviewAbout 90 seconds aloud

Open with

I would start by accepting that we will not delete records from backups. Physical backups and WAL are hard to edit, object lock forbids it, and PITR would replay the original inserts anyway.

Then, if they want more

Instead I would make personal data unreadable everywhere. With crypto-shredding, each person's or tenant's personal fields are encrypted with their own key in a key service. Erasure means destroying that key, and every copy, production, replicas, backups and archives, becomes ciphertext nobody can read, at the same moment.

Fields the seven-year rules actually require, like invoice amounts and dates, stay in the clear, so the design work is classifying fields with legal. Second, I would separate purposes: operational PITR backups keep everything but expire in a few weeks, while long-term archives are extracts of only the required records, with personal data minimised and also encrypted per subject.

Third, a documented procedure agreed with legal: retention per jurisdiction, when retention overrides erasure, how fast erasure happens, and an erasure log of opaque ids that must be replayed whenever a backup is restored into use, before it serves traffic. And finally testing: restore drills erase synthetic subjects first, then check they are unreadable in the restored copy.

The key service's own backups need short retention, so destroyed keys do not live on there.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Retention rules require keeping database backups for 7 years in some jurisdictions and...": https://scrivio-interview-library.netlify.app/databases/replication-and-ha/fd490a24b7/