◇ OpenCyber Academy
Technologist · Chapter 22 · English

Chapter 22 — Privacy and data protection: automation

Open, free learning for anyone who wants to protect people and technology. No account is required to read this text or its worked answers.

Chapter 22 — Privacy and data protection: automation

Lesson map

Lesson 22 published. Map, example, EX064.

flowchart TD
  N0["Learning outcomes"]
  N1["22.1 The rule"]
  N2["22.2 Results"]
  N3["22.3 Exceptions"]
  N4["22.4 Verification"]
  N5["Lab — Automated inactive account deletion"]
  N0 --> N1 --> N2 --> N3 --> N4 --> N5
  N5 --> EX["Worked example"]
  EX --> Q["Exercise EX064"]

Logical drawing

flowchart LR
  N0["Learning outcomes"]
  N1["22.1 The rule"]
  N2["22.2 Results"]
  N3["22.3 Exceptions"]
  N4["22.4 Verification"]
  N5["Lab — Automated inactive account deletion"]
  N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> Q["EX064"]
[Learning outcomes]
    |
    v
[22.1 The rule]
    |
    v
[22.2 Results]
    |
    v
[22.3 Exceptions]
    |
    v
[22.4 Verification]
    |
    v
[Lab — Automated inactive account deletion]
    |
    v
[Worked example] --> [Exercise EX064]

Learning outcomes

You will (1) automate deletion of inactive accounts; (2) handle exceptions; (3) verify results.

22.1 The rule

Quayside deletes accounts inactive for over two years, after a warning email thirty days before. Two years matches Quayside's documented retention schedule, which balances members returning after long breaks against storage limitation. The warning email gives members a chance to keep their account by logging in. Accounts with unresolved debt are held, because Quayside needs records to pursue or settle the debt, which is a documented exception with its own retention period. The thirty-day warning lets members keep accounts by logging in.

22.2 Results

The lab processes 3,000 accounts: 73 warning emails this month, 1,116 to delete, and 37 held for outstanding debt. The lab script reads a synthetic list of 3,000 accounts with last activity dates and debt flags. It calculates which accounts reach the warning point this month, which have passed the deletion point and which are held. The script prints only counts, not identities, and writes the list of affected account numbers to a protected file for the operations team. No names appear in console output or logs.

22.3 Exceptions

Accounts with debt are held under a documented basis until resolved. Aisha logs every decision. Each held account is reviewed monthly, and once the debt is settled or written off the account enters deletion in the next run. Aisha considers other possible exceptions, such as legal claims, and adds a manual hold flag that only the data protection officer can set. Every hold records who set it, when and why. Unexplained holds are cleared at the monthly review. In the first run, all thirty-seven holds have a recorded debt reference.

22.4 Verification

She samples deleted accounts to confirm removal across systems. Mr. Reilly notes that automation enforces storage limitation reliably. For a sample of twenty deleted accounts, she checks the membership system, app database, email platform and booking vendor. In the first run, the booking vendor still holds three accounts because its deletion interface had failed. The fix adds a confirmation step from the vendor. Deletion is now verified, not assumed, which supports the accountability principle in Article 5(2). Twenty samples each month are enough to detect a broken vendor link.

Lab — Automated inactive account deletion

# Automated deletion of inactive app accounts: inactive > 24 months, warn at 23 months, skip accounts with debt.
import random
r = random.Random(13)
acc = [(r.randint(0, 40), r.random() < 0.03) for _ in range(3000)]  # months inactive, outstanding debt
warn = sum(1 for m, d in acc if m == 23); dele = sum(1 for m, d in acc if m > 24 and not d); hold = sum(1 for m, d in acc if m > 24 and d)
print(f"accounts {len(acc)}; warning emails this month {warn}; delete {dele}; held for outstanding debt {hold}")

Run with python3 lab_inactive.py. Verified output:

accounts 3000; warning emails this month 73; delete 1116; held for outstanding debt 37

Worked example

Aisha's job sends 73 warnings, deletes 1,116 accounts and holds 37 with debt, and samples deletions.

Synthetic case. Accounts are synthetic.

Errors and limits

Deletion must reach backups and vendors over time.

Exercises

Continue studying — lesson 22 (chapter 22 of 30)

← Chapter 21 · Course chapter index · Chapter 23 →

Continue to the next authored lesson.