backupdrill 2.11.0 → 2.11.1
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 +19 -9
- package/dist/auth-archive.d.ts +31 -0
- package/dist/auth-archive.js +423 -0
- package/dist/auth-backup.d.ts +10 -1
- package/dist/auth-backup.js +134 -0
- package/dist/auth-drill.d.ts +41 -2
- package/dist/auth-drill.js +135 -22
- package/dist/backup.js +46 -3
- package/dist/drill.d.ts +28 -1
- package/dist/drill.js +183 -2
- package/dist/recovery-doc.d.ts +7 -0
- package/dist/recovery-doc.js +13 -1
- package/package.json +4 -2
- package/plugin/README.md +1 -1
- package/plugin/skills/supabase-backup/SKILL.md +5 -5
- package/plugin/skills/supabase-backup/assets/scheduled-backup.yml +1 -1
package/dist/drill.js
CHANGED
|
@@ -281,7 +281,7 @@ async function startEphemeralPostgres(image, major, resourceName) {
|
|
|
281
281
|
"postgres",
|
|
282
282
|
"-q",
|
|
283
283
|
]);
|
|
284
|
-
return { containerId, port, connString, restoreJobs: tuning.restoreJobs, teardown, forgetInterruptCleanup };
|
|
284
|
+
return { containerId, port, connString, offline: false, restoreJobs: tuning.restoreJobs, teardown, forgetInterruptCleanup };
|
|
285
285
|
}
|
|
286
286
|
catch {
|
|
287
287
|
await new Promise((r) => setTimeout(r, 500));
|
|
@@ -295,6 +295,183 @@ async function startEphemeralPostgres(image, major, resourceName) {
|
|
|
295
295
|
throw error;
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
+
// ── 断网跑 SQL(模拟注册用,2.11.1)────────────────────────────────
|
|
299
|
+
/** 沙箱容器当前接着的 Docker 网络 */
|
|
300
|
+
async function containerNetworks(containerId) {
|
|
301
|
+
const { stdout } = await execFileAsync("docker", ["inspect", "-f", "{{json .NetworkSettings.Networks}}", containerId], {
|
|
302
|
+
timeout: 15_000,
|
|
303
|
+
});
|
|
304
|
+
return Object.keys(JSON.parse(stdout.trim() || "null") ?? {});
|
|
305
|
+
}
|
|
306
|
+
/** 在容器里跑一条命令(docker exec);timeoutMs 或 signal 到了就杀掉本地的 docker exec 客户端 */
|
|
307
|
+
function containerExec(containerId, command, opts) {
|
|
308
|
+
return new Promise((resolve) => {
|
|
309
|
+
const proc = spawn("docker", [
|
|
310
|
+
"exec",
|
|
311
|
+
...(opts.input !== undefined ? ["-i"] : []),
|
|
312
|
+
...(opts.env ?? []).flatMap((kv) => ["-e", kv]),
|
|
313
|
+
containerId,
|
|
314
|
+
...command,
|
|
315
|
+
], { stdio: [opts.input !== undefined ? "pipe" : "ignore", "pipe", "ignore"] });
|
|
316
|
+
let stdout = "";
|
|
317
|
+
proc.stdout.on("data", (d) => {
|
|
318
|
+
// 只要我们自己 select 出来的那一行;封顶,不让输出无限长
|
|
319
|
+
if (stdout.length < 64 * 1024)
|
|
320
|
+
stdout += d.toString();
|
|
321
|
+
});
|
|
322
|
+
let killed = false;
|
|
323
|
+
const kill = () => {
|
|
324
|
+
killed = true;
|
|
325
|
+
proc.kill("SIGKILL");
|
|
326
|
+
};
|
|
327
|
+
const timer = setTimeout(kill, opts.timeoutMs);
|
|
328
|
+
if (opts.signal?.aborted)
|
|
329
|
+
kill();
|
|
330
|
+
opts.signal?.addEventListener("abort", kill, { once: true });
|
|
331
|
+
proc.on("error", () => { });
|
|
332
|
+
proc.on("close", (code) => {
|
|
333
|
+
clearTimeout(timer);
|
|
334
|
+
opts.signal?.removeEventListener("abort", kill);
|
|
335
|
+
resolve({ code, stdout, killed });
|
|
336
|
+
});
|
|
337
|
+
if (opts.input !== undefined) {
|
|
338
|
+
proc.stdin.on("error", () => { });
|
|
339
|
+
proc.stdin.end(opts.input);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
/** 容器里用 psql 跑 SQL(默认走 unix socket,不经网络)。官方镜像对本地 socket 和 127.0.0.1 都是 trust */
|
|
344
|
+
const PSQL = ["psql", "-X", "-q", "-tA", "-v", "ON_ERROR_STOP=1", "-U", "postgres", "-d", "postgres"];
|
|
345
|
+
/** 模拟注册在容器里的几样痕迹,都带同一个随机标记:取消标记文件、psql 的 pid 文件、会话的 application_name */
|
|
346
|
+
function signupTraces(marker) {
|
|
347
|
+
if (!/^[0-9a-f]{16}$/.test(marker))
|
|
348
|
+
throw new Error("bad sign-up marker");
|
|
349
|
+
return {
|
|
350
|
+
cancelFile: `/tmp/backupdrill-signup-${marker}.cancel`,
|
|
351
|
+
pidFile: `/tmp/backupdrill-signup-${marker}.pid`,
|
|
352
|
+
appName: `backupdrill-signup-${marker}`,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* 模拟注册本地那一侧(docker exec 客户端)最多等多久;导出供测试调短,产品里不改。
|
|
357
|
+
* launchPauseSeconds 只给测试用:在启动脚本"看过取消标记"和"exec psql"之间停一会儿,复现最坏的时序
|
|
358
|
+
*/
|
|
359
|
+
export const OFFLINE_SIGNUP_LIMITS = { psqlMs: 6 * 60 * 1000, launchPauseSeconds: 0 };
|
|
360
|
+
/**
|
|
361
|
+
* 容器里启动模拟注册的脚本。和 stopSignup 的约定:**先占位、再看取消**。
|
|
362
|
+
* - 启动脚本先独占创建 pid 文件(set -C),写进自己的 pid,然后才看取消标记,有就退出;
|
|
363
|
+
* - stopSignup 先建取消标记,然后才看 pid 文件。
|
|
364
|
+
* 所以 stopSignup 没看到 pid 文件,启动脚本之后一定会看到取消标记而退出;看到了,就按 pid 杀掉它——
|
|
365
|
+
* 不管它还是 sh(停在 exec 之前)还是已经 exec 成了 psql,pid 都是同一个。
|
|
366
|
+
*
|
|
367
|
+
* psql 经 127.0.0.1 连(断网后 loopback 还在):走 unix socket 时 inet_client_addr() 是 NULL,
|
|
368
|
+
* 真实注册经 TCP 进来,要客户端地址的触发器会被误判成坏的。官方镜像 loopback 是 trust;
|
|
369
|
+
* 万一不是,用容器自己的 POSTGRES_PASSWORD
|
|
370
|
+
*/
|
|
371
|
+
function signupLauncher(marker) {
|
|
372
|
+
const { cancelFile, pidFile } = signupTraces(marker);
|
|
373
|
+
const pause = Math.max(0, Math.floor(OFFLINE_SIGNUP_LIMITS.launchPauseSeconds));
|
|
374
|
+
return (`set -C; echo $$ > ${pidFile} || exit 99; [ -e ${cancelFile} ] && exit 99; ` +
|
|
375
|
+
(pause ? `sleep ${pause}; ` : "") +
|
|
376
|
+
`PGPASSWORD="$POSTGRES_PASSWORD" exec ${PSQL.join(" ")} -h 127.0.0.1`);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* 停掉一次没有正常结束的模拟注册,并等到它在容器里确实没了,到 deadline(时间戳)为止。本地的 docker exec 客户端被杀掉
|
|
380
|
+
* (超时、叫停)时,容器里的那次启动照样在跑,甚至可能还没起来。按 signupLauncher 的约定:
|
|
381
|
+
* 1. 先建取消标记,再看 pid 文件:没有 pid 文件 = 它以后也不会启动;有 = 那个进程(sh 或 psql)还活着就杀掉;
|
|
382
|
+
* 2. 终止它的会话(按 application_name,或者语句里带着这次的随机标记——触发器能改 application_name)。
|
|
383
|
+
* 进程没了、会话也没了才算停下来。每条 docker 命令的时限也截在 deadline 之内,整体不会超过它
|
|
384
|
+
*/
|
|
385
|
+
async function stopSignup(containerId, marker, deadline) {
|
|
386
|
+
const { cancelFile, pidFile, appName } = signupTraces(marker);
|
|
387
|
+
// 输出 "alive":还有进程(刚杀掉,或者 pid 文件刚建、还没写进 pid),下一轮再看
|
|
388
|
+
const killLauncher = `touch ${cancelFile}; if [ -e ${pidFile} ]; then p=$(cat ${pidFile}); ` +
|
|
389
|
+
`if [ -z "$p" ]; then echo alive; ` +
|
|
390
|
+
`else c=$(cat /proc/$p/comm 2>/dev/null); if [ "$c" = sh ] || [ "$c" = psql ]; then kill -9 "$p"; echo alive; fi; fi; fi; true`;
|
|
391
|
+
const sessions = `select count(pg_terminate_backend(pid)) from pg_stat_activity where pid <> pg_backend_pid() ` +
|
|
392
|
+
`and (application_name = '${appName}' or query like '%${marker}%')`;
|
|
393
|
+
const left = () => deadline - Date.now();
|
|
394
|
+
while (left() > 0) {
|
|
395
|
+
const killed = await containerExec(containerId, ["sh", "-c", killLauncher], { timeoutMs: Math.max(1, left()) });
|
|
396
|
+
if (killed.code !== 0 || left() <= 0)
|
|
397
|
+
return false;
|
|
398
|
+
const sessionsLeft = await containerExec(containerId, [...PSQL, "-c", sessions], { timeoutMs: Math.max(1, left()) });
|
|
399
|
+
if (sessionsLeft.code !== 0)
|
|
400
|
+
return false;
|
|
401
|
+
if (killed.stdout.trim() === "" && sessionsLeft.stdout.trim() === "0")
|
|
402
|
+
return true;
|
|
403
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(500, Math.max(0, left()))));
|
|
404
|
+
}
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
/** 停掉模拟注册最多等多久(整体,从开始停算起) */
|
|
408
|
+
const STOP_SIGNUP_MS = 15_000;
|
|
409
|
+
/**
|
|
410
|
+
* 模拟注册用的"断网跑 SQL"(见 auth-drill.ts OfflineSandbox)。
|
|
411
|
+
*
|
|
412
|
+
* 为什么是临时断网,而不是一开始就不给沙箱联网:CLI 和 pg_restore 都从主机经发布的端口连沙箱,
|
|
413
|
+
* --network none 和 --internal 网络都发布不了端口。所以恢复、校验照旧,只在最后的模拟注册之前把容器从所有
|
|
414
|
+
* 网络上摘下来(只剩 loopback),经 docker exec 里的 psql 连 127.0.0.1 跑(见 signupLauncher)。
|
|
415
|
+
*
|
|
416
|
+
* **断了就不再接回**:能确认的只有会话和那个 psql 都没了,确认不了触发器有没有留下别的东西(后台进程等),
|
|
417
|
+
* 一接回它们就又能连出去。所以模拟注册是这个沙箱上的最后一件事,跑完沙箱就销毁。--keep 要留下沙箱时
|
|
418
|
+
* 根本不跑模拟注册(见 drillDump),留下的沙箱和 2.11.0 一样连得上。
|
|
419
|
+
* 每一步之前都看一眼是否已被叫停:叫停后(报告可能已经出了)不再断开任何网络。摘不干净就不跑。
|
|
420
|
+
*/
|
|
421
|
+
/** @internal 演练内部用;导出只为测试能直接对一个容器验证断网、叫停和超时收尾 */
|
|
422
|
+
export function offlineSandbox(pg) {
|
|
423
|
+
let running = null;
|
|
424
|
+
// 同一次注册的收尾只做一次:本地超时、叫停、演练那边的 stopOfflineSessions 谁先来谁启动,其余的等同一个结果
|
|
425
|
+
const stopping = new Map();
|
|
426
|
+
const stopOnce = (marker) => {
|
|
427
|
+
let p = stopping.get(marker);
|
|
428
|
+
if (!p)
|
|
429
|
+
stopping.set(marker, (p = stopSignup(pg.containerId, marker, Date.now() + STOP_SIGNUP_MS)));
|
|
430
|
+
return p;
|
|
431
|
+
};
|
|
432
|
+
return {
|
|
433
|
+
offline: () => pg.offline,
|
|
434
|
+
async stopOfflineSessions() {
|
|
435
|
+
if (running)
|
|
436
|
+
await stopOnce(running);
|
|
437
|
+
},
|
|
438
|
+
async runOffline(script, marker, signal) {
|
|
439
|
+
const { appName } = signupTraces(marker);
|
|
440
|
+
const stopped = () => {
|
|
441
|
+
if (signal?.aborted)
|
|
442
|
+
throw new Error("stopped");
|
|
443
|
+
};
|
|
444
|
+
stopped();
|
|
445
|
+
const networks = await containerNetworks(pg.containerId);
|
|
446
|
+
for (const network of networks) {
|
|
447
|
+
stopped();
|
|
448
|
+
await execFileAsync("docker", ["network", "disconnect", network, pg.containerId], { timeout: 30_000 });
|
|
449
|
+
// 只记确认过的状态:这一个网络已经摘掉了,之后不会再接回
|
|
450
|
+
pg.offline = true;
|
|
451
|
+
}
|
|
452
|
+
const left = await containerNetworks(pg.containerId);
|
|
453
|
+
if (left.length)
|
|
454
|
+
throw new Error(`the sandbox is still on ${left.join(", ")}`);
|
|
455
|
+
pg.offline = true;
|
|
456
|
+
stopped();
|
|
457
|
+
running = marker;
|
|
458
|
+
const result = await containerExec(pg.containerId, ["sh", "-c", signupLauncher(marker)], { input: script, timeoutMs: OFFLINE_SIGNUP_LIMITS.psqlMs, signal, env: [`PGAPPNAME=${appName}`] });
|
|
459
|
+
// 本地超时或被叫停:容器里的那次模拟注册可能还在跑,先确实停掉它,再交出结果(之后沙箱才会被销毁)
|
|
460
|
+
if (result.killed || signal?.aborted) {
|
|
461
|
+
// 超时收尾时演练可能正同时销毁沙箱:容器已经停了(或没了),里面的注册也就跟着没了,不必提示
|
|
462
|
+
const stillThere = () => execFileAsync("docker", ["inspect", "-f", "{{.State.Running}}", pg.containerId], { timeout: 10_000 }).then((r) => r.stdout.trim() === "true", () => false);
|
|
463
|
+
if (!(await stopOnce(marker)) && (await stillThere())) {
|
|
464
|
+
log.warn("Couldn't confirm the stopped test sign-up ended inside the drill sandbox; it stays off the network until it is removed.");
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return { code: result.killed ? null : result.code, stdout: result.stdout };
|
|
468
|
+
},
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
/** --keep 留下的沙箱:和 2.11.0 一样给连接串(留沙箱时不跑模拟注册,它一直连得上),另给一条进容器的命令 */
|
|
472
|
+
function keptSandboxInfo(pg) {
|
|
473
|
+
return { containerId: pg.containerId, connString: pg.connString, inspect: `docker exec -it ${pg.containerId.slice(0, 12)} psql -U postgres` };
|
|
474
|
+
}
|
|
298
475
|
// 只有这些特征说明恢复失败源于沙箱缺扩展(限定类型/schema 解析不到、扩展装不上)。
|
|
299
476
|
// 真实 Supabase 项目的 manifest 几乎必然含沙箱装不上的托管扩展(pg_graphql 等),
|
|
300
477
|
// 若不按特征过滤,任何硬失败(归档损坏、OOM…)都会被误归因到沙箱。
|
|
@@ -728,6 +905,10 @@ export async function drillDump(dumpPath, manifest, snapshot, preChecks = [], op
|
|
|
728
905
|
// 托管 worker 在这一步前后换磁盘守卫的规则:Auth 阶段吃紧只叫停这一节,不判演练失败
|
|
729
906
|
begin: opts.supervision ? () => opts.supervision.observe({ phase: "auth" }) : undefined,
|
|
730
907
|
stop: opts.supervision?.authStop,
|
|
908
|
+
sandbox: offlineSandbox(pg),
|
|
909
|
+
// --keep 要留下这个沙箱时不跑模拟注册:断了网就不能再接回,留下的沙箱就连不上了(脚本靠 keptSandbox.connString)。
|
|
910
|
+
// 结论(pass)这时已经定了,只有真的会留沙箱(演练没通过)才跳过
|
|
911
|
+
skipSignup: opts.keepSandboxOnFailure && !pass ? "--keep leaves the sandbox connected so you can inspect it" : undefined,
|
|
731
912
|
});
|
|
732
913
|
if (authSection) {
|
|
733
914
|
report.auth = authSection;
|
|
@@ -739,7 +920,7 @@ export async function drillDump(dumpPath, manifest, snapshot, preChecks = [], op
|
|
|
739
920
|
}
|
|
740
921
|
if (opts.keepSandboxOnFailure && !pass) {
|
|
741
922
|
// 写进报告让 --keep 可被脚本消费(拿连接串排查),不只靠人眼看日志
|
|
742
|
-
report.keptSandbox =
|
|
923
|
+
report.keptSandbox = keptSandboxInfo(pg);
|
|
743
924
|
}
|
|
744
925
|
return report;
|
|
745
926
|
}
|
package/dist/recovery-doc.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { Manifest } from "./manifest.js";
|
|
2
|
+
/**
|
|
3
|
+
* 原样写进 RECOVERY.md 的一段文字(例如 Auth 失败的原因,里面有从系统目录读来的约束名、索引名):放进代码段里,
|
|
4
|
+
* Markdown 不再解释里面的任何东西(链接、强调、HTML,GFM 也不会把裸网址自动变成链接)。按 CommonMark 的规则,
|
|
5
|
+
* 包住它的反引号要比里面最长的一串反引号多一个;两边各加一个空格,文字本身以反引号或空格开头结尾也不受影响。
|
|
6
|
+
* 控制字符换成可见的转义,名字里的换行不会让这一段断开
|
|
7
|
+
*/
|
|
8
|
+
export declare function markdownCode(text: string): string;
|
|
2
9
|
/** 生成手册所需的非秘密快照坐标。刻意不收连接串/密钥类型——签名即防线。 */
|
|
3
10
|
export interface RecoveryDocContext {
|
|
4
11
|
snapshot: string;
|
package/dist/recovery-doc.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { recoveryGrantsSql } from "./grants.js";
|
|
2
2
|
import { plainSchemaName, restorableAuthObjects } from "./auth-backup.js";
|
|
3
3
|
import { authRestoreNotes, CLEAR_PENDING_AUTH_SQL } from "./auth-restore.js";
|
|
4
|
+
/**
|
|
5
|
+
* 原样写进 RECOVERY.md 的一段文字(例如 Auth 失败的原因,里面有从系统目录读来的约束名、索引名):放进代码段里,
|
|
6
|
+
* Markdown 不再解释里面的任何东西(链接、强调、HTML,GFM 也不会把裸网址自动变成链接)。按 CommonMark 的规则,
|
|
7
|
+
* 包住它的反引号要比里面最长的一串反引号多一个;两边各加一个空格,文字本身以反引号或空格开头结尾也不受影响。
|
|
8
|
+
* 控制字符换成可见的转义,名字里的换行不会让这一段断开
|
|
9
|
+
*/
|
|
10
|
+
export function markdownCode(text) {
|
|
11
|
+
const visible = text.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g, (ch) => `\\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
12
|
+
const longestRun = Math.max(0, ...[...visible.matchAll(/`+/g)].map((m) => m[0].length));
|
|
13
|
+
const fence = "`".repeat(longestRun + 1);
|
|
14
|
+
return `${fence} ${visible} ${fence}`;
|
|
15
|
+
}
|
|
4
16
|
function quoteSqlIdent(name) {
|
|
5
17
|
return `"${name.replace(/"/g, '""')}"`;
|
|
6
18
|
}
|
|
@@ -37,7 +49,7 @@ export function authRecoveryText(manifest, place) {
|
|
|
37
49
|
(pg_dump custom format, ${mb(auth.dump.bytes)} MB, sha256 \`${auth.dump.sha256}\`) — ${auth.rows.users.toLocaleString("en-US")} users, ${auth.rows.identities.toLocaleString("en-US")} sign-in identities
|
|
38
50
|
`
|
|
39
51
|
: manifest.auth
|
|
40
|
-
? `- **Supabase Auth users**: not in this snapshot (${AUTH_NOT_INCLUDED_TEXT[manifest.auth.reason ?? ""] ?? manifest.auth.reason ?? "not captured"})
|
|
52
|
+
? `- **Supabase Auth users**: not in this snapshot (${AUTH_NOT_INCLUDED_TEXT[manifest.auth.reason ?? ""] ?? markdownCode(manifest.auth.reason ?? "not captured")})
|
|
41
53
|
`
|
|
42
54
|
: "";
|
|
43
55
|
// 空目标检查用的 schema 列表(SQL 字符串字面量,单引号按 SQL 规则加倍)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "backupdrill",
|
|
3
|
-
"version": "2.11.
|
|
4
|
-
"description": "Open-source CLI to back up a Supabase project
|
|
3
|
+
"version": "2.11.1",
|
|
4
|
+
"description": "Open-source CLI to back up a Supabase project to your own S3/R2/B2 bucket (the Postgres database, Auth users when your role can read them, and Storage files once you add the project's Storage S3 keys), then run a restore drill that proves the backup restores.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"backupdrill": "dist/index.js"
|
|
@@ -50,6 +50,8 @@
|
|
|
50
50
|
"cloudflare-r2",
|
|
51
51
|
"backblaze-b2",
|
|
52
52
|
"disaster-recovery",
|
|
53
|
+
"supabase-auth",
|
|
54
|
+
"backup-verification",
|
|
53
55
|
"healthchecks",
|
|
54
56
|
"pi-package"
|
|
55
57
|
],
|
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.
|
|
10
|
+
The agent runs every command as `npx -y backupdrill@2.11.0`, 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.
|
|
10
|
+
Always run it as `npx -y backupdrill@2.11.0 <command>`, so every run uses the same version. Every command and option is documented at [backupdrill.com/docs/cli](https://backupdrill.com/docs/cli); check there before using an option this skill doesn't mention.
|
|
11
11
|
|
|
12
12
|
If the user asks what Supabase already backs up on their plan, wants a plain `pg_dump` backup without the CLI, or wants to test a restore by hand, read [references/postgres-backup-basics.md](references/postgres-backup-basics.md).
|
|
13
13
|
|
|
@@ -71,7 +71,7 @@ Every backup reads the whole database, and every configured Storage file, out of
|
|
|
71
71
|
```sh
|
|
72
72
|
( set +x; unset DATABASE_URL $(env | sed -n 's/^\(BACKUPDRILL_[A-Za-z0-9_]*\)=.*/\1/p')
|
|
73
73
|
set -a; . ./.env.backupdrill 2>/dev/null || { echo ".env.backupdrill could not be loaded" >&2; exit 1; }; set +a
|
|
74
|
-
npx -y backupdrill@2.
|
|
74
|
+
npx -y backupdrill@2.11.0 estimate --plan pro )
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
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.
|
|
@@ -82,7 +82,7 @@ Use `--plan free`, `pro` or `team` to match their Supabase plan, and read the pr
|
|
|
82
82
|
report="$(mktemp "${TMPDIR:-/tmp}/backupdrill-backup.XXXXXX")" || exit 1; echo "stdout → $report"
|
|
83
83
|
( set +x; unset DATABASE_URL $(env | sed -n 's/^\(BACKUPDRILL_[A-Za-z0-9_]*\)=.*/\1/p')
|
|
84
84
|
set -a; . ./.env.backupdrill 2>/dev/null || { echo ".env.backupdrill could not be loaded" >&2; exit 1; }; set +a
|
|
85
|
-
npx -y backupdrill@2.
|
|
85
|
+
npx -y backupdrill@2.11.0 backup ) > "$report"
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
- 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.
|
|
@@ -95,7 +95,7 @@ report="$(mktemp "${TMPDIR:-/tmp}/backupdrill-backup.XXXXXX")" || exit 1; echo "
|
|
|
95
95
|
```sh
|
|
96
96
|
( set +x; unset DATABASE_URL $(env | sed -n 's/^\(BACKUPDRILL_[A-Za-z0-9_]*\)=.*/\1/p')
|
|
97
97
|
set -a; . ./.env.backupdrill 2>/dev/null || { echo ".env.backupdrill could not be loaded" >&2; exit 1; }; set +a
|
|
98
|
-
npx -y backupdrill@2.
|
|
98
|
+
npx -y backupdrill@2.11.0 drill )
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
- 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.
|
|
@@ -114,7 +114,7 @@ A restore writes data, so go step by step and let the user drive.
|
|
|
114
114
|
```sh
|
|
115
115
|
( set +x; unset DATABASE_URL $(env | sed -n 's/^\(BACKUPDRILL_[A-Za-z0-9_]*\)=.*/\1/p')
|
|
116
116
|
set -a; . ./.env.backupdrill 2>/dev/null || { echo ".env.backupdrill could not be loaded" >&2; exit 1; }; set +a
|
|
117
|
-
npx -y backupdrill@2.
|
|
117
|
+
npx -y backupdrill@2.11.0 restore --database --target-supabase-url https://<target-ref>.supabase.co --dry-run )
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
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`.
|
|
@@ -99,7 +99,7 @@ jobs:
|
|
|
99
99
|
|
|
100
100
|
- name: Run backupdrill
|
|
101
101
|
# Pinned so every run uses the same CLI. Raise it on purpose when you upgrade.
|
|
102
|
-
run: npx -y backupdrill@2.
|
|
102
|
+
run: npx -y backupdrill@2.11.0 backup
|
|
103
103
|
env:
|
|
104
104
|
# --- required ---
|
|
105
105
|
BACKUPDRILL_DATABASE_URL: ${{ secrets.BACKUPDRILL_DATABASE_URL }}
|