backupdrill 2.7.2 → 2.7.3
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.
package/README.md
CHANGED
|
@@ -265,14 +265,45 @@ every process on the machine):
|
|
|
265
265
|
|
|
266
266
|
## GitHub Action / scheduled backups
|
|
267
267
|
|
|
268
|
-
Want this running on a schedule without paying for a server?
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
268
|
+
Want this running on a schedule without paying for a server? Use the [Supabase Backup with BackupDrill](https://github.com/backupdrill/supabase-backup-action) action. It installs `pg_dump` 17 from the PostgreSQL apt repo (PGDG), runs `backupdrill backup` with the newest 2.x release of this CLI, and with `drill: "true"` restores the new snapshot into a throwaway Postgres on the runner and checks it.
|
|
269
|
+
|
|
270
|
+
```yaml
|
|
271
|
+
# .github/workflows/supabase-backup.yml in your own (private) repo
|
|
272
|
+
name: supabase-backup
|
|
273
|
+
on:
|
|
274
|
+
schedule:
|
|
275
|
+
- cron: "0 3 * * 0" # weekly; read the egress section above before going daily
|
|
276
|
+
workflow_dispatch: {}
|
|
277
|
+
permissions:
|
|
278
|
+
contents: read
|
|
279
|
+
concurrency:
|
|
280
|
+
group: supabase-backup
|
|
281
|
+
cancel-in-progress: false
|
|
282
|
+
jobs:
|
|
283
|
+
backup:
|
|
284
|
+
runs-on: ubuntu-latest
|
|
285
|
+
steps:
|
|
286
|
+
- uses: backupdrill/supabase-backup-action@v1
|
|
287
|
+
with:
|
|
288
|
+
database-url: ${{ secrets.BACKUPDRILL_DATABASE_URL }}
|
|
289
|
+
s3-bucket: ${{ secrets.BACKUPDRILL_S3_BUCKET }}
|
|
290
|
+
s3-access-key-id: ${{ secrets.BACKUPDRILL_S3_ACCESS_KEY_ID }}
|
|
291
|
+
s3-secret-access-key: ${{ secrets.BACKUPDRILL_S3_SECRET_ACCESS_KEY }}
|
|
292
|
+
s3-endpoint: ${{ secrets.BACKUPDRILL_S3_ENDPOINT }}
|
|
293
|
+
s3-region: ${{ secrets.BACKUPDRILL_S3_REGION }}
|
|
294
|
+
drill: "true"
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Add the secrets under Settings → Secrets and variables → Actions:
|
|
298
|
+
|
|
299
|
+
- **Required:** `BACKUPDRILL_DATABASE_URL`, `BACKUPDRILL_S3_BUCKET`, `BACKUPDRILL_S3_ACCESS_KEY_ID`, `BACKUPDRILL_S3_SECRET_ACCESS_KEY`
|
|
300
|
+
- **Optional (destination):** `BACKUPDRILL_S3_ENDPOINT` (for R2/B2) and `BACKUPDRILL_S3_REGION` (AWS S3 needs the bucket's region; R2 works with the default `auto`). A readable project name goes in the `project-name` input.
|
|
301
|
+
- **Optional (alerts):** `BACKUPDRILL_PING_URL`, passed as `ping-url`. See [Alerts with Healthchecks.io](#alerts-with-healthchecksio).
|
|
302
|
+
- **Optional (Storage files):** the four `BACKUPDRILL_SUPABASE_STORAGE_*` values, passed as the `supabase-storage-endpoint`, `-region`, `-access-key-id` and `-secret-access-key` inputs. Leave them out to back up the database only.
|
|
303
|
+
|
|
304
|
+
The action's README lists every input and output.
|
|
305
|
+
|
|
306
|
+
Prefer a plain workflow file? [`examples/scheduled-backup.yml`](examples/scheduled-backup.yml) runs the backup without the action and without a drill. Copy it into your own repo at `.github/workflows/scheduled-backup.yml` and add the same secrets. (It lives under `examples/` here so GitHub doesn't try to run it in this repo.) It runs daily and can also be started by hand from the Actions tab.
|
|
276
307
|
|
|
277
308
|
Before switching to a **daily** schedule, read the egress-cost section above — every run is egress on your Supabase bill.
|
|
278
309
|
|
package/dist/restore-engine.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare function refFromStorageEndpoint(endpoint: string): string | null;
|
|
|
27
27
|
export interface ClassifiedPass {
|
|
28
28
|
/** allowlist 命中数(环境预期/托管冲突)——如实入报告,不算失败 */
|
|
29
29
|
expectedSkips: number;
|
|
30
|
-
/** 真失败(
|
|
30
|
+
/** 真失败(压缩空白、按 FAILURE_DETAIL_MAX_CHARS 截断的错误块) */
|
|
31
31
|
failures: string[];
|
|
32
32
|
}
|
|
33
33
|
export interface EngineResult {
|
|
@@ -73,17 +73,6 @@ export declare function sandboxManagedError(dumpedSchemas?: string[]): RegExp;
|
|
|
73
73
|
/** 默认形态(什么托管 schema 都没转):兼容层与"只转 public"的托管 worker 路径。 */
|
|
74
74
|
export declare const SANDBOX_MANAGED_ERROR: RegExp;
|
|
75
75
|
export declare const SCHEMA_EXISTS_ERROR: RegExp;
|
|
76
|
-
/**
|
|
77
|
-
* 把 pg_restore 的 stderr 拆成单个错误块并按 allowlist 分类。
|
|
78
|
-
* **只对 ERROR 那一行分类**:不看 "Command was:" 之后的语句文本,也不看 DETAIL /
|
|
79
|
-
* CONTEXT / LINE 行。前者的理由:一个恰好引用 auth.uid 的用户对象因"损坏/语法错误"
|
|
80
|
-
* 失败时,会被误判成预期跳过。后者(交叉审查 2026-09-11 复现):DETAIL 里带的是**行值**
|
|
81
|
-
* —— `Key (message)=(relation "auth.users" does not exist) already exists` 是用户的数据,
|
|
82
|
-
* 不是错误原因,拿它匹配等于让用户数据决定演练结论;一条失败的唯一索引就能这样混过去。
|
|
83
|
-
* Postgres 的主消息恒为单行,且在块的第一行(`pg_restore: error: ... ERROR: …`)。
|
|
84
|
-
* 抽出 `ERROR:` 之后的那段作为主消息,allowlist 对它**整条**匹配(两端锚定,见上);
|
|
85
|
-
* 没有 `ERROR:` 前缀的块(归档器致命错等)整行当主消息,锚定的 allowlist 不会认它 → 失败。
|
|
86
|
-
*/
|
|
87
76
|
export declare function classifyBlocks(stderr: string, allow: RegExp): ClassifiedPass;
|
|
88
77
|
/**
|
|
89
78
|
* 一遍恢复的最终裁决,两条独立规则:
|
package/dist/restore-engine.js
CHANGED
|
@@ -258,6 +258,12 @@ const NEVER_MATCH = /(?!)/;
|
|
|
258
258
|
* 抽出 `ERROR:` 之后的那段作为主消息,allowlist 对它**整条**匹配(两端锚定,见上);
|
|
259
259
|
* 没有 `ERROR:` 前缀的块(归档器致命错等)整行当主消息,锚定的 allowlist 不会认它 → 失败。
|
|
260
260
|
*/
|
|
261
|
+
/**
|
|
262
|
+
* 单条失败写进报告时的长度上限。要装得下 ERROR 行 + DETAIL 行:外键校验失败时,被引用的父表名和
|
|
263
|
+
* 完整的键只在 DETAIL 里,原先 200 字符会把它们截掉(2026-10-30 一次外键失败的报告只剩半个 UUID)。
|
|
264
|
+
* 末尾的 "Command was:" 语句最先被截,无妨。
|
|
265
|
+
*/
|
|
266
|
+
const FAILURE_DETAIL_MAX_CHARS = 500;
|
|
261
267
|
export function classifyBlocks(stderr, allow) {
|
|
262
268
|
const blocks = stderr
|
|
263
269
|
.split(/(?=pg_restore: error:)/)
|
|
@@ -271,7 +277,7 @@ export function classifyBlocks(stderr, allow) {
|
|
|
271
277
|
expectedSkips += 1;
|
|
272
278
|
}
|
|
273
279
|
else {
|
|
274
|
-
failures.push(block.replace(/\s+/g, " ").trim().slice(0,
|
|
280
|
+
failures.push(block.replace(/\s+/g, " ").trim().slice(0, FAILURE_DETAIL_MAX_CHARS));
|
|
275
281
|
}
|
|
276
282
|
}
|
|
277
283
|
return { expectedSkips, failures };
|
package/package.json
CHANGED
package/plugin/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Back up a Supabase project to a bucket you own and prove the backup restores, by
|
|
|
7
7
|
- `drill` restores a snapshot into a throwaway Postgres in Docker, checks that the tables and their data came back, and checksums a sample of the Storage files.
|
|
8
8
|
- `restore` puts a snapshot into a new, empty Supabase project, after a dry run and only once you confirm the target.
|
|
9
9
|
|
|
10
|
-
The agent runs every command as `npx -y backupdrill@2.7.
|
|
10
|
+
The agent runs every command as `npx -y backupdrill@2.7.2`, so the CLI version stays fixed.
|
|
11
11
|
|
|
12
12
|
## What you need
|
|
13
13
|
|
|
@@ -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.7.
|
|
10
|
+
Always run it as `npx -y backupdrill@2.7.2 <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.7.
|
|
72
|
+
npx -y backupdrill@2.7.2 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,7 +80,7 @@ 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.7.
|
|
83
|
+
npx -y backupdrill@2.7.2 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.
|
|
@@ -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.7.
|
|
96
|
+
npx -y backupdrill@2.7.2 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,7 +112,7 @@ 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.7.
|
|
115
|
+
npx -y backupdrill@2.7.2 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`.
|
|
@@ -95,7 +95,7 @@ jobs:
|
|
|
95
95
|
|
|
96
96
|
- name: Run backupdrill
|
|
97
97
|
# Pinned so every run uses the same CLI. Raise it on purpose when you upgrade.
|
|
98
|
-
run: npx -y backupdrill@2.7.
|
|
98
|
+
run: npx -y backupdrill@2.7.2 backup
|
|
99
99
|
env:
|
|
100
100
|
# --- required ---
|
|
101
101
|
BACKUPDRILL_DATABASE_URL: ${{ secrets.BACKUPDRILL_DATABASE_URL }}
|