|
| 1 | +# backups-worker – accessing backups |
| 2 | + |
| 3 | +This Worker serves Mongo backups from R2 at `https://backups.berkeleytime.com`: |
| 4 | + |
| 5 | +- `GET /public/*` → `prod-mongo-public-backups` |
| 6 | +- `GET /private/*` → `prod-mongo-backups` |
| 7 | + |
| 8 | +Behavior notes: |
| 9 | + |
| 10 | +- Only `GET` and `HEAD` are allowed. |
| 11 | +- `/private/*` requires Cloudflare Access, and the Worker cryptographically verifies `cf-access-jwt-assertion`. |
| 12 | +- Legacy public paths like `/daily/*` still resolve from the public bucket for compatibility. |
| 13 | + |
| 14 | +## Required private-route auth config |
| 15 | + |
| 16 | +Set these Worker variables for JWT verification: |
| 17 | + |
| 18 | +- `CLOUDFLARE_ACCESS_TEAM_DOMAIN` (for example: `your-team.cloudflareaccess.com`) |
| 19 | +- `CLOUDFLARE_ACCESS_AUDIENCE` (Access app AUD tag; comma-separated if you need multiple values) |
| 20 | + |
| 21 | +If either variable is missing or the token is invalid, `/private/*` returns `403`. |
| 22 | + |
| 23 | +## 1. Install `cloudflared` |
| 24 | + |
| 25 | +```bash |
| 26 | +brew install cloudflare/cloudflare/cloudflared |
| 27 | +``` |
| 28 | + |
| 29 | +## 2. Fetch a public backup |
| 30 | + |
| 31 | +Public does **not** require authentication: |
| 32 | + |
| 33 | +```bash |
| 34 | +curl -f -o "prod_public_backup-YYYYMMDD.gz" \ |
| 35 | + "https://backups.berkeleytime.com/public/daily/prod_public_backup-YYYYMMDD.gz" |
| 36 | +printf "\033[33mNotice: Public backups are redacted and are not a comprehensive dataset. Use private backups (Cloudflare Access required) for full data.\033[0m\n" |
| 37 | +``` |
| 38 | + |
| 39 | +Replace `YYYYMMDD` with the date. |
| 40 | + |
| 41 | +## 3. Log in for private backups |
| 42 | + |
| 43 | +Private backups require Cloudflare Access. |
| 44 | + |
| 45 | +```bash |
| 46 | +cloudflared access login https://backups.berkeleytime.com |
| 47 | +``` |
| 48 | + |
| 49 | +## 4. Fetch a private backup |
| 50 | + |
| 51 | +After logging in: |
| 52 | + |
| 53 | +```bash |
| 54 | +cloudflared access curl \ |
| 55 | + "https://backups.berkeleytime.com/private/hourly/prod_backup-YYYYMMDDHH.gz" \ |
| 56 | + -o "prod_backup-YYYYMMDDHH.gz" |
| 57 | +``` |
| 58 | + |
| 59 | +For monthly persistent backups: |
| 60 | + |
| 61 | +```bash |
| 62 | +cloudflared access curl \ |
| 63 | + "https://backups.berkeleytime.com/private/persistent/prod_backup-YYYYMMDD.gz" \ |
| 64 | + -o "prod_backup-YYYYMMDD.gz" |
| 65 | +``` |
0 commit comments