Recoverable and visible: restore drills and checking what the firewall blocked
Locking the door leaves two more things: whether you can recover when something goes wrong, and whether anyone is knocking. Rebuilding from GitHub from scratch showed me that files deliberately kept out of git were missing from the backup; looking back at firewall events showed me the rules really were doing their job. Includes step-by-step instructions for a restore drill and for reviewing events.
The first four chapters are all about “locking the door.” This chapter covers the other half, which most personal site owners skip:
- Recoverable: if the site or data breaks, or the account is compromised, can you rebuild from backups?
- Visible: is anyone knocking? Are the rules actually working, and are they blocking the wrong people?
Restore drill: rebuilding from GitHub from scratch
My site’s source code lives in a private GitHub repo. I had assumed “having GitHub means having a backup,” until I actually rebuilt the site from zero.
| Step | Result |
|---|---|
| In an empty folder, do a fresh clone from GitHub and install packages from the lock file | Succeeded |
| Run the full build and checks | Failed the first time: the pre-publish privacy scan could not find the privacy filter list |
| Cause | That list is deliberately kept out of git (its contents are the private terms to filter out), so GitHub doesn’t have it |
| Is there another copy? | Yes: the computer’s daily local backup separately copies hand-written files like this one that aren’t in git, and the hashes match on both sides |
| Run again, pointing to that copy | Passed |
There was a misjudgment on my part here: during the drill, I first recorded that “this list has no copy anywhere,” and only later found another backup layer. Before declaring “no backup,” check every backup layer, not just git.
The easiest things to miss are exactly the files deliberately kept out of git: the privacy list and local secret config files (for example .dev.vars and .env). Keeping them out of git is right, but you need to decide separately where their backups live.
Hands-on: your own restore drill
- Open a new empty folder (don’t do this inside your original folder).
- Clone your website repo with
git clone. - Install packages per the project’s instructions (for example
npm ci), then run a full build once. - If it fails, check which file is missing: most often it’s one of those files kept out of git. Write down where their backups are.
- Once the missing files are restored and the build succeeds, the drill has passed. You don’t need to actually deploy; being able to build a site identical to the live one is enough.
The database needs backups too
My site has a small database (Cloudflare D1) that records page view counts. It exists only in the cloud, and I had never exported it.
The official docs provide a command to export it as an SQL file:
npx wrangler d1 export <資料庫名稱> --remote --output=./backup.sqlAfter exporting, check that it actually restores: I loaded the SQL into an empty local SQLite database and confirmed that it loaded without errors and that I could count the rows in each table. Only then did I count the backup as valid.
Afterwards I wired this into the deployment script: every deployment also exports a copy, automatically verifies that it loads, and keeps only the most recent 5 days of copies (multiple deployments on the same day keep just one). This way the backup doesn’t need a separate login, since deployment is already logged in.
What the firewall blocked
After the rules from chapter 4 went live, I looked back at the requests blocked over the past 7 days:
- Everything blocked was the output of that custom rule: automated scanning for paths like
.env,.git,/wp-admin/. - One source did a concentrated scan.
- One probe came in through a Cloudflare Worker as a relay: scanners also use cloud services as stepping stones.
- No false positives: none of the blocked requests were paths an ordinary reader would visit.
The blocked traffic is evidence: only by looking back after the rules went live could I tell that they were really doing something and not blocking the wrong people.
Hands-on: reviewing security events
- In the Cloudflare dashboard, select your domain → Security → Analytics, then switch to the Events tab (security events). The interface text varies slightly with redesigns.
- Set the time range to the last 7 days.
- First look at the summary grouped by action (the free plan’s official docs say it only has sampled logs, so a summary chart may not appear), then look through the event list to find which rule blocked each request.
- Then open a few entries and check their paths: if they are all scanning paths, that’s right. If you see a normal page path being blocked, that’s a false positive, so go back and fix the rule.
When sharing screenshots, be careful: the events page shows source IPs, and dashboard pages often include the account email and account ID. Blur them before you share a screenshot.
My deploy script prints the events-page URL when it finishes, so I glance at it while logged in. If I want the program to read events itself, I would need a read-only API token; that has to be created by me in person, and I haven’t done it yet.
Sources
- Cloudflare D1: Import and export data (Official documentation)
- Cloudflare WAF: Security Events (Official documentation)
← Previous:Three gates at the website edge: blocking scan paths, limiting password attempts, and adding headers
Next:Keep the protections from silently failing: one checklist plus periodic re-checks →
Email subscriptions will open later. For now, you can follow new articles and work with RSS.