backupdrill 2.9.2 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +23 -5
  2. package/dist/auth-backup.d.ts +110 -0
  3. package/dist/auth-backup.js +383 -0
  4. package/dist/auth-drill.d.ts +69 -0
  5. package/dist/auth-drill.js +469 -0
  6. package/dist/auth-restore.d.ts +120 -0
  7. package/dist/auth-restore.js +633 -0
  8. package/dist/backup.d.ts +17 -0
  9. package/dist/backup.js +372 -19
  10. package/dist/config.d.ts +9 -0
  11. package/dist/config.js +17 -0
  12. package/dist/drill.d.ts +24 -3
  13. package/dist/drill.js +36 -0
  14. package/dist/dump-sql.d.ts +6 -0
  15. package/dist/dump-sql.js +31 -0
  16. package/dist/external-refs.d.ts +6 -1
  17. package/dist/external-refs.js +5 -0
  18. package/dist/index.js +67 -3
  19. package/dist/lib.d.ts +9 -3
  20. package/dist/lib.js +4 -2
  21. package/dist/manifest.d.ts +63 -0
  22. package/dist/manifest.js +78 -0
  23. package/dist/orphaned-foreign-keys.d.ts +13 -0
  24. package/dist/orphaned-foreign-keys.js +75 -25
  25. package/dist/pgbin.d.ts +7 -0
  26. package/dist/pgbin.js +24 -0
  27. package/dist/ping.js +1 -0
  28. package/dist/recovery-doc.d.ts +25 -0
  29. package/dist/recovery-doc.js +232 -53
  30. package/dist/restore-engine.d.ts +73 -1
  31. package/dist/restore-engine.js +155 -77
  32. package/dist/restore-record.d.ts +47 -0
  33. package/dist/restore-record.js +57 -0
  34. package/dist/restore.d.ts +64 -0
  35. package/dist/restore.js +348 -34
  36. package/dist/snapshot-store.d.ts +13 -0
  37. package/dist/snapshot-store.js +25 -0
  38. package/dist/snapshots.d.ts +2 -0
  39. package/dist/snapshots.js +10 -3
  40. package/package.json +1 -1
  41. package/plugin/README.md +1 -1
  42. package/plugin/skills/supabase-backup/SKILL.md +7 -7
  43. package/plugin/skills/supabase-backup/assets/scheduled-backup.yml +6 -1
@@ -7,7 +7,7 @@ description: Use when the user wants to back up a Supabase project to their own
7
7
 
8
8
  backupdrill is an open-source (MIT) command-line tool. `backup` dumps the project's Postgres database with `pg_dump`, copies Storage files too once their S3 keys are set, and writes everything to a bucket the user owns, with a checksummed `manifest.json` and a `RECOVERY.md` in every snapshot. `drill` restores a snapshot into a throwaway Postgres in Docker and checks that it came back. The CLI runs on the user's machine. It talks to their Supabase project, their bucket and the local Docker daemon, and sends nothing to BackupDrill.
9
9
 
10
- Always run it as `npx -y backupdrill@2.9.2 <command>`, so every run uses the same version.
10
+ Always run it as `npx -y backupdrill@2.10.0 <command>`, so every run uses the same version.
11
11
 
12
12
  You need a shell on the user's machine for this. If you don't have one, walk the user through the same commands instead of running them.
13
13
 
@@ -69,7 +69,7 @@ Every backup reads the whole database, and every configured Storage file, out of
69
69
  ```sh
70
70
  ( set +x; unset DATABASE_URL $(env | sed -n 's/^\(BACKUPDRILL_[A-Za-z0-9_]*\)=.*/\1/p')
71
71
  set -a; . ./.env.backupdrill 2>/dev/null || { echo ".env.backupdrill could not be loaded" >&2; exit 1; }; set +a
72
- npx -y backupdrill@2.9.2 estimate --plan pro )
72
+ npx -y backupdrill@2.10.0 estimate --plan pro )
73
73
  ```
74
74
 
75
75
  Use `--plan free`, `pro` or `team` to match their Supabase plan, and read the projection back before suggesting a daily schedule. On a large database, suggest weekly.
@@ -80,12 +80,12 @@ Use `--plan free`, `pro` or `team` to match their Supabase plan, and read the pr
80
80
  report="$(mktemp "${TMPDIR:-/tmp}/backupdrill-backup.XXXXXX")" || exit 1; echo "stdout → $report"
81
81
  ( set +x; unset DATABASE_URL $(env | sed -n 's/^\(BACKUPDRILL_[A-Za-z0-9_]*\)=.*/\1/p')
82
82
  set -a; . ./.env.backupdrill 2>/dev/null || { echo ".env.backupdrill could not be loaded" >&2; exit 1; }; set +a
83
- npx -y backupdrill@2.9.2 backup ) > "$report"
83
+ npx -y backupdrill@2.10.0 backup ) > "$report"
84
84
  ```
85
85
 
86
86
  - The progress lines on stderr show where everything went (`Dumping → s3://…`, `Manifest written → s3://…`) and end with `Backup complete — N tables + M Storage files`. stdout goes to the file named on the first line, a new one each run that only the user can read: one line of JSON with the whole manifest, which lists every table and Storage file, so read only the fields you need from it.
87
87
  - Report the table count, the Storage file count (or that it was database only), and where the snapshot landed: `<prefix>/<project>/<timestamp>/` in their bucket, holding `dump.pgcustom`, `manifest.json`, `RECOVERY.md` and, with Storage keys set, `storage/`.
88
- - By default only the `public` schema is dumped (add their own schemas with `--schema`), so Supabase-managed schemas such as `auth` and `storage` aren't in it. The dump has no grants; the manifest records what `anon`, `authenticated` and `service_role` were granted, and `restore` and `drill` set that back.
88
+ - By default only the `public` schema is dumped (add their own schemas with `--schema`), so Supabase-managed schemas such as `auth` and `storage` aren't in it. Since 2.10.0 the Auth users (`auth.users` and `auth.identities`) go into a second archive, `auth.dump`, when the database role can read them, unless they turned that off with `--no-auth` or `BACKUPDRILL_AUTH=off`. The dump has no grants; the manifest records what `anon`, `authenticated` and `service_role` were granted, and `restore` and `drill` set that back.
89
89
  - The CLI never deletes anything in the bucket. Old snapshots are cleaned up by the bucket's own lifecycle rules, if the user sets any.
90
90
 
91
91
  ## Prove the backup restores (drill)
@@ -93,7 +93,7 @@ report="$(mktemp "${TMPDIR:-/tmp}/backupdrill-backup.XXXXXX")" || exit 1; echo "
93
93
  ```sh
94
94
  ( set +x; unset DATABASE_URL $(env | sed -n 's/^\(BACKUPDRILL_[A-Za-z0-9_]*\)=.*/\1/p')
95
95
  set -a; . ./.env.backupdrill 2>/dev/null || { echo ".env.backupdrill could not be loaded" >&2; exit 1; }; set +a
96
- npx -y backupdrill@2.9.2 drill )
96
+ npx -y backupdrill@2.10.0 drill )
97
97
  ```
98
98
 
99
99
  - It reads the latest snapshot from the bucket, restores it into a throwaway Postgres container, runs its checks and removes the container. It doesn't connect to the Supabase project. The first run pulls a Postgres image from Docker Hub.
@@ -112,12 +112,12 @@ A restore writes data, so go step by step and let the user drive.
112
112
  ```sh
113
113
  ( set +x; unset DATABASE_URL $(env | sed -n 's/^\(BACKUPDRILL_[A-Za-z0-9_]*\)=.*/\1/p')
114
114
  set -a; . ./.env.backupdrill 2>/dev/null || { echo ".env.backupdrill could not be loaded" >&2; exit 1; }; set +a
115
- npx -y backupdrill@2.9.2 restore --database --target-supabase-url https://<target-ref>.supabase.co --dry-run )
115
+ npx -y backupdrill@2.10.0 restore --database --target-supabase-url https://<target-ref>.supabase.co --dry-run )
116
116
  ```
117
117
 
118
118
  Leave out `--target-supabase-url` when the snapshot is database only. To write Storage files to a local folder instead of the new project, use `--storage-dir ./recovered`.
119
119
  4. Show the dry-run result. It starts with `Dry run for snapshot <timestamp>`; note that timestamp. Run the real restore only after the user asks for it and gives you the target ref. Then replace `--dry-run` with `--snapshot <timestamp> --confirm-target <target-ref>`, using the timestamp from the dry run and exactly the ref they gave, so a backup that lands in between can't change what gets restored. Send stdout to a new `mktemp` file the same way as `backup` (with `backupdrill-restore.XXXXXX` as the name): the JSON result can be long. If the user wants an older snapshot, pass `--snapshot` to both runs.
120
- 5. Tell them what a restore doesn't bring back: Auth users, secret values and Edge Functions. They need to set those up again. The `API grants` check line says what access `anon`, `authenticated` and `service_role` got; for a snapshot taken before 2.9.0 it is Supabase's old default access in `public`, so they should revoke it on anything they kept private. The snapshot's `RECOVERY.md` has a "Not covered" section on this.
120
+ 5. Tell them what a restore doesn't bring back: Auth sessions and MFA factors, Auth settings (sign-in providers, SMTP, redirect URLs), secret values and Edge Functions. A snapshot that has Auth users (its manifest says so under `auth`) restores them with the database in one transaction; everyone signs in again afterwards. Snapshots without them, including every snapshot taken before 2.10.0, have no Auth users to restore. They need to set those up again. The `API grants` check line says what access `anon`, `authenticated` and `service_role` got; for a snapshot taken before 2.9.0 it is Supabase's old default access in `public`, so they should revoke it on anything they kept private. The snapshot's `RECOVERY.md` has a "Not covered" section on this.
121
121
  6. Once they're done, suggest they delete the two `TARGET` lines from `.env.backupdrill`.
122
122
 
123
123
  ## Run it on a schedule
@@ -26,6 +26,10 @@
26
26
  # BACKUPDRILL_SCHEMAS Comma-separated schemas to dump, e.g. public,audit
27
27
  # (default: public). Use the same value as your
28
28
  # local runs, or scheduled backups miss schemas.
29
+ # BACKUPDRILL_AUTH Supabase Auth users (auth.users + auth.identities)
30
+ # are backed up when the database role can read
31
+ # them. "off" leaves them out; "on" makes a backup
32
+ # that can't include them exit with code 3.
29
33
  # BACKUPDRILL_S3_PREFIX Key prefix in the bucket (default: backupdrill).
30
34
  # Keep it the same as local runs so drills and
31
35
  # restores find these snapshots.
@@ -95,7 +99,7 @@ jobs:
95
99
 
96
100
  - name: Run backupdrill
97
101
  # Pinned so every run uses the same CLI. Raise it on purpose when you upgrade.
98
- run: npx -y backupdrill@2.9.2 backup
102
+ run: npx -y backupdrill@2.10.0 backup
99
103
  env:
100
104
  # --- required ---
101
105
  BACKUPDRILL_DATABASE_URL: ${{ secrets.BACKUPDRILL_DATABASE_URL }}
@@ -107,6 +111,7 @@ jobs:
107
111
  BACKUPDRILL_S3_REGION: ${{ secrets.BACKUPDRILL_S3_REGION }}
108
112
  BACKUPDRILL_PROJECT_NAME: ${{ secrets.BACKUPDRILL_PROJECT_NAME }}
109
113
  BACKUPDRILL_SCHEMAS: ${{ secrets.BACKUPDRILL_SCHEMAS }}
114
+ BACKUPDRILL_AUTH: ${{ secrets.BACKUPDRILL_AUTH }}
110
115
  BACKUPDRILL_S3_PREFIX: ${{ secrets.BACKUPDRILL_S3_PREFIX }}
111
116
  BACKUPDRILL_S3_FORCE_PATH_STYLE: ${{ secrets.BACKUPDRILL_S3_FORCE_PATH_STYLE }}
112
117
  # --- optional: also back up Supabase Storage files (set all four) ---