backupdrill 2.9.2 → 2.10.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 +49 -5
- package/dist/auth-backup.d.ts +110 -0
- package/dist/auth-backup.js +383 -0
- package/dist/auth-drill.d.ts +69 -0
- package/dist/auth-drill.js +469 -0
- package/dist/auth-restore.d.ts +120 -0
- package/dist/auth-restore.js +633 -0
- package/dist/backup.d.ts +17 -0
- package/dist/backup.js +372 -19
- package/dist/config.d.ts +9 -0
- package/dist/config.js +17 -0
- package/dist/drill.d.ts +24 -3
- package/dist/drill.js +43 -3
- package/dist/dump-sql.d.ts +6 -0
- package/dist/dump-sql.js +31 -0
- package/dist/external-refs.d.ts +6 -1
- package/dist/external-refs.js +5 -0
- package/dist/index.js +67 -3
- package/dist/lib.d.ts +9 -3
- package/dist/lib.js +4 -2
- package/dist/manifest.d.ts +63 -0
- package/dist/manifest.js +78 -0
- package/dist/orphaned-foreign-keys.d.ts +13 -0
- package/dist/orphaned-foreign-keys.js +75 -25
- package/dist/pgbin.d.ts +7 -0
- package/dist/pgbin.js +24 -0
- package/dist/ping.js +1 -0
- package/dist/recovery-doc.d.ts +25 -0
- package/dist/recovery-doc.js +232 -53
- package/dist/restore-engine.d.ts +73 -1
- package/dist/restore-engine.js +155 -77
- package/dist/restore-record.d.ts +47 -0
- package/dist/restore-record.js +57 -0
- package/dist/restore.d.ts +64 -0
- package/dist/restore.js +348 -34
- package/dist/snapshot-store.d.ts +13 -0
- package/dist/snapshot-store.js +25 -0
- package/dist/snapshots.d.ts +2 -0
- package/dist/snapshots.js +10 -3
- package/package.json +1 -1
- package/plugin/README.md +1 -1
- package/plugin/skills/supabase-backup/SKILL.md +9 -7
- package/plugin/skills/supabase-backup/assets/scheduled-backup.yml +6 -1
- package/plugin/skills/supabase-backup/references/postgres-backup-basics.md +94 -0
package/dist/restore.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { mkdtemp, mkdir, rm, readdir, lstat } from "node:fs/promises";
|
|
2
3
|
import { createWriteStream } from "node:fs";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
@@ -6,20 +7,26 @@ import { pipeline } from "node:stream/promises";
|
|
|
6
7
|
import { GetObjectCommand } from "@aws-sdk/client-s3";
|
|
7
8
|
import { parseManifest } from "./manifest.js";
|
|
8
9
|
import { s3SnapshotStore } from "./snapshot-store.js";
|
|
9
|
-
import { restoreDatabaseArtifact, installExtensions, projectRefOf, refFromStorageEndpoint, assertNoHostOverride, normalizeHost, } from "./restore-engine.js";
|
|
10
|
+
import { afterCommit, deferredForeignKeysOf, restoreDatabaseArtifact, userObjectCountSql, installExtensions, projectRefOf, refFromStorageEndpoint, assertNoHostOverride, normalizeHost, } from "./restore-engine.js";
|
|
10
11
|
import { checkExternalReferences, describe } from "./external-refs.js";
|
|
11
12
|
import { verifyRestored } from "./drill.js";
|
|
12
13
|
import { restoreStorage, planStorageRestore, } from "./storage-restore.js";
|
|
13
14
|
import { connectPg } from "./supabase-ca.js";
|
|
15
|
+
import { connectCancellable } from "./auth-backup.js";
|
|
14
16
|
import { orphanedForeignKeysCheck } from "./orphaned-foreign-keys.js";
|
|
15
17
|
import { grantsCheck } from "./grants.js";
|
|
16
18
|
import { localPgRestoreMajor, restoreToolTargetBlocker } from "./pgbin.js";
|
|
19
|
+
import { describeTarget, restoreRecordKey } from "./restore-record.js";
|
|
20
|
+
import { AUTH_TABLE_KEYS, authRestoreFailureMessage, authRestoreNotes, targetIdentity, transactionOutcome, authRestorePreflight, largeObjectEntries, psqlProblem, readAuthArchive, restoreWithAuth, } from "./auth-restore.js";
|
|
17
21
|
import { parsePgDumpMajor } from "./backup.js";
|
|
18
22
|
import { log } from "./log.js";
|
|
19
23
|
/** 归档可读性要求:pg_restore 必须 ≥ max(写入工具版本, 源服务端版本)——格式跟随写入工具。 */
|
|
20
24
|
export function requiredRestoreToolMajor(manifest) {
|
|
21
25
|
return Math.max(parsePgDumpMajor(manifest.database.pgDumpVersion) ?? 0, parseInt(manifest.database.serverVersion, 10) || 0);
|
|
22
26
|
}
|
|
27
|
+
/** 恢复后不管快照里有什么都要手工做的事(Auth 配置不在数据库里) */
|
|
28
|
+
const AUTH_AFTER_RESTORE = "Everyone signs in again: sessions aren't in the snapshot. Reconfigure Auth in the Supabase dashboard before " +
|
|
29
|
+
"switching your app over: sign-in providers (OAuth client IDs and secrets), SMTP, redirect URLs, the site URL and SSO.";
|
|
23
30
|
/**
|
|
24
31
|
* restore 无源库配置时的占位连接串(纯 flag 驱动、没有 backupdrill.config.json 的场景)。
|
|
25
32
|
* 同源阻断门对它不生效——没有可比对的源;有真实源配置时阻断门照常工作。
|
|
@@ -193,23 +200,7 @@ async function assertEmptyTarget(targetUrl, schemas, alsoRestoringStorage) {
|
|
|
193
200
|
async function userObjectCount(targetUrl, schemas) {
|
|
194
201
|
const client = await connectPg(targetUrl);
|
|
195
202
|
try {
|
|
196
|
-
const res = await client.query(`select
|
|
197
|
-
(select count(*) from pg_class c join pg_namespace n on n.oid = c.relnamespace
|
|
198
|
-
where n.nspname = any($1::text[]) and c.relkind in ('r','p','m','v','S','f','c')
|
|
199
|
-
and not (exists (select 1 from pg_depend d where d.deptype = 'e'
|
|
200
|
-
and ((d.classid = 'pg_class'::regclass and d.objid = c.oid)
|
|
201
|
-
-- 扩展建的复合类型(dblink 的 dblink_pkey_results)登记在类型上,不在关系上
|
|
202
|
-
or (d.classid = 'pg_type'::regclass and d.objid = c.reltype)))
|
|
203
|
-
and not exists (select 1 from pg_extension e where c.oid = any(e.extconfig))))
|
|
204
|
-
+ (select count(*) from pg_proc p join pg_namespace n on n.oid = p.pronamespace
|
|
205
|
-
where n.nspname = any($1::text[])
|
|
206
|
-
and not exists (select 1 from pg_depend d where d.classid = 'pg_proc'::regclass
|
|
207
|
-
and d.objid = p.oid and d.deptype = 'e'))
|
|
208
|
-
+ (select count(*) from pg_type t join pg_namespace n on n.oid = t.typnamespace
|
|
209
|
-
where n.nspname = any($1::text[]) and t.typtype in ('e','d','r')
|
|
210
|
-
and not exists (select 1 from pg_depend d where d.classid = 'pg_type'::regclass
|
|
211
|
-
and d.objid = t.oid and d.deptype = 'e'))
|
|
212
|
-
as n`, [schemas]);
|
|
203
|
+
const res = await client.query(`select ${userObjectCountSql("$1::text[]")} as n`, [schemas]);
|
|
213
204
|
return Number(res.rows[0].n);
|
|
214
205
|
}
|
|
215
206
|
finally {
|
|
@@ -277,7 +268,7 @@ function logExternalReferences(check, schemas, printProblems) {
|
|
|
277
268
|
* 有目标库时会把 dump 下载到本地临时目录读一遍(2.7.0 起):归档校验和、指向备份之外的外键,
|
|
278
269
|
* 这两类墙只有看了 dump 才撞得到。下载是读桶,目标库上仍然只有 select。
|
|
279
270
|
*/
|
|
280
|
-
async function dryRunPreflight(config, manifest, targetUrl, storageTarget, alsoRestoringStorage, reader) {
|
|
271
|
+
async function dryRunPreflight(config, manifest, targetUrl, storageTarget, alsoRestoringStorage, reader, skipAuth) {
|
|
281
272
|
const blockers = [];
|
|
282
273
|
const db = manifest.database;
|
|
283
274
|
const mb = (n) => (n / 1024 / 1024).toFixed(1);
|
|
@@ -287,7 +278,17 @@ async function dryRunPreflight(config, manifest, targetUrl, storageTarget, alsoR
|
|
|
287
278
|
? `storage: ${manifest.storage.fileCount} files, ${mb(manifest.storage.totalBytes)} MB` +
|
|
288
279
|
(manifest.storage.buckets ? `, ${manifest.storage.buckets.length} bucket(s) with attributes` : ", bucket attributes not captured")
|
|
289
280
|
: "storage: none (database-only snapshot)");
|
|
290
|
-
|
|
281
|
+
if (manifest.auth?.status === "included") {
|
|
282
|
+
log.ok(`auth: ${manifest.auth.rows.users.toLocaleString("en-US")} users ` +
|
|
283
|
+
`(${manifest.auth.rows.identities.toLocaleString("en-US")} identities)` +
|
|
284
|
+
(skipAuth ? " — not restored (--skip-auth)" : ""));
|
|
285
|
+
}
|
|
286
|
+
if (manifest.auth?.status === "included" && !skipAuth) {
|
|
287
|
+
log.warn("not covered: Auth sessions and MFA factors, Auth settings, secret values, Edge Functions, most platform settings");
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
log.warn("not covered: Auth users/sessions, secret values, Edge Functions, most platform settings");
|
|
291
|
+
}
|
|
291
292
|
// 双目标一致性(dry-run 也要查,不能绿灯放行到正式执行才拒):库与 Storage
|
|
292
293
|
// 两个入口指向不同项目 = 配置错了一个
|
|
293
294
|
const dbRef = targetUrl ? projectRefOf(targetUrl) : null;
|
|
@@ -373,7 +374,7 @@ async function dryRunPreflight(config, manifest, targetUrl, storageTarget, alsoR
|
|
|
373
374
|
await client.end();
|
|
374
375
|
}
|
|
375
376
|
if (toolReadsArchive) {
|
|
376
|
-
blockers.push(...(await inspectDumpForTarget(manifest, targetUrl, reader)));
|
|
377
|
+
blockers.push(...(await inspectDumpForTarget(manifest, targetUrl, reader, skipAuth)));
|
|
377
378
|
}
|
|
378
379
|
else {
|
|
379
380
|
log.warn("dump not inspected (archive checksum, references outside the backup) — needs a working pg_restore");
|
|
@@ -420,7 +421,7 @@ export function restoreFailureAdvice(failure) {
|
|
|
420
421
|
"--config max_locks_per_transaction=256 --project-ref <target-ref> --experimental");
|
|
421
422
|
}
|
|
422
423
|
/** dry-run 的读 dump 部分:下载到临时目录,对校验和,查指向备份之外的外键。返回 blocker。 */
|
|
423
|
-
async function inspectDumpForTarget(manifest, targetUrl, reader) {
|
|
424
|
+
async function inspectDumpForTarget(manifest, targetUrl, reader, skipAuth) {
|
|
424
425
|
// 正式恢复先装扩展再查外键;dry-run 不装,被引用的表可能要等扩展装上才有
|
|
425
426
|
const installed = await installedExtensions(targetUrl);
|
|
426
427
|
const pendingExtensions = (manifest.database.extensions ?? [])
|
|
@@ -443,12 +444,24 @@ async function inspectDumpForTarget(manifest, targetUrl, reader) {
|
|
|
443
444
|
return ["archive checksum does not match the manifest"];
|
|
444
445
|
}
|
|
445
446
|
log.ok(`archive integrity: sha256 matches (${sha256.slice(0, 12)}…)`);
|
|
447
|
+
let withAuth = false;
|
|
448
|
+
try {
|
|
449
|
+
const plan = await planAuthRestore(manifest, reader, targetUrl, dumpPath, workdir, skipAuth);
|
|
450
|
+
withAuth = !!plan.archive;
|
|
451
|
+
if (withAuth)
|
|
452
|
+
log.ok("auth: the target can take the Auth users; they'd be restored with the database in one transaction");
|
|
453
|
+
}
|
|
454
|
+
catch (error) {
|
|
455
|
+
log.error(`auth: ${error.message}`);
|
|
456
|
+
return [error.message];
|
|
457
|
+
}
|
|
446
458
|
try {
|
|
447
459
|
const check = await checkExternalReferences({
|
|
448
460
|
dumpPath,
|
|
449
461
|
dumpedSchemas: manifest.database.schemas,
|
|
450
462
|
targetUrl,
|
|
451
463
|
pendingExtensions,
|
|
464
|
+
restoredTables: withAuth ? AUTH_TABLES : [],
|
|
452
465
|
});
|
|
453
466
|
return logExternalReferences(check, manifest.database.schemas, true);
|
|
454
467
|
}
|
|
@@ -461,6 +474,52 @@ async function inspectDumpForTarget(manifest, targetUrl, reader) {
|
|
|
461
474
|
await rm(workdir, { recursive: true, force: true }).catch(() => { });
|
|
462
475
|
}
|
|
463
476
|
}
|
|
477
|
+
/** 和数据库在同一个事务里写进去的两张 Auth 表 */
|
|
478
|
+
const AUTH_TABLES = [
|
|
479
|
+
{ schema: "auth", name: "users" },
|
|
480
|
+
{ schema: "auth", name: "identities" },
|
|
481
|
+
];
|
|
482
|
+
/**
|
|
483
|
+
* 决定这次恢复写不写 Auth 用户,要写就把 auth.dump 下载、校验、读好,并在目标上做完只读预检。
|
|
484
|
+
* 任何一项过不了就抛错(写入之前);dry-run 和正式执行共用。快照里没有 Auth 用户时什么都不做
|
|
485
|
+
*/
|
|
486
|
+
async function planAuthRestore(manifest, reader, targetUrl, dumpPath, workdir, skipAuth) {
|
|
487
|
+
const auth = manifest.auth;
|
|
488
|
+
if (auth?.status !== "included")
|
|
489
|
+
return {};
|
|
490
|
+
if (skipAuth) {
|
|
491
|
+
log.warn("The snapshot's Auth users are not restored (--skip-auth); the database is restored the way 2.9 did.");
|
|
492
|
+
return { result: { restored: false, reason: "--skip-auth" } };
|
|
493
|
+
}
|
|
494
|
+
if (!reader.downloadAuthDump) {
|
|
495
|
+
const reason = "this snapshot location can't read the Auth archive";
|
|
496
|
+
log.warn(`The snapshot's Auth users are not restored: ${reason}; the database is restored the way 2.9 did.`);
|
|
497
|
+
return { result: { restored: false, reason } };
|
|
498
|
+
}
|
|
499
|
+
const problem = await psqlProblem();
|
|
500
|
+
if (problem) {
|
|
501
|
+
throw new Error(`restoring the Auth users needs psql: ${problem}. Or pass --skip-auth to restore the database without them.`);
|
|
502
|
+
}
|
|
503
|
+
log.step("Downloading the Auth archive…");
|
|
504
|
+
const authPath = join(workdir, "auth.dump");
|
|
505
|
+
const { sha256 } = await reader.downloadAuthDump(manifest, authPath);
|
|
506
|
+
if (sha256 !== auth.dump.sha256) {
|
|
507
|
+
throw new Error(`the Auth archive's sha256 ${sha256.slice(0, 12)}… does not match the manifest's ${auth.dump.sha256.slice(0, 12)}… — ` +
|
|
508
|
+
"refusing to restore a corrupted archive");
|
|
509
|
+
}
|
|
510
|
+
const archive = await readAuthArchive(authPath, manifest, workdir);
|
|
511
|
+
const blockers = await authRestorePreflight(targetUrl, archive);
|
|
512
|
+
// pg_restore 写 SQL 时在大对象前后自带 BEGIN/COMMIT,会把这个事务提前提交
|
|
513
|
+
const largeObjects = await largeObjectEntries(dumpPath);
|
|
514
|
+
if (largeObjects) {
|
|
515
|
+
blockers.push("the snapshot has large objects, which can't be restored in the same transaction as the Auth users yet; " +
|
|
516
|
+
"pass --skip-auth to restore the database alone, then copy the Auth users by hand (see RECOVERY.md)");
|
|
517
|
+
}
|
|
518
|
+
if (blockers.length) {
|
|
519
|
+
throw new Error(`the Auth users can't be restored into this target:\n - ${blockers.join("\n - ")}`);
|
|
520
|
+
}
|
|
521
|
+
return { archive };
|
|
522
|
+
}
|
|
464
523
|
/** 目标上已经装了哪些扩展。 */
|
|
465
524
|
async function installedExtensions(targetUrl) {
|
|
466
525
|
const client = await connectPg(targetUrl);
|
|
@@ -490,7 +549,8 @@ export async function runRestore(config, opts) {
|
|
|
490
549
|
const store = opts.store ?? s3SnapshotStore(config);
|
|
491
550
|
const reader = await store.openSnapshot(opts.snapshot);
|
|
492
551
|
const snapshot = reader.name;
|
|
493
|
-
const
|
|
552
|
+
const rawManifest = await reader.readManifest();
|
|
553
|
+
const manifest = parseManifest(rawManifest);
|
|
494
554
|
// Storage 目标构造即校验(https + 恰为 <ref>.supabase.co):service key 只发往
|
|
495
555
|
// 已验证的 Supabase 项目源;目标库连接串拒绝 host 覆盖(身份判定=实际写入目标)
|
|
496
556
|
// 两个字段必须成对:只给其一时静默退回"本地下载"会让库级调用方把受保护文件
|
|
@@ -548,7 +608,7 @@ export async function runRestore(config, opts) {
|
|
|
548
608
|
// dry-run:只读预检后直接返回,零写入(PRD §5.3.2)
|
|
549
609
|
if (opts.dryRun) {
|
|
550
610
|
log.step(`Dry run for snapshot ${snapshot} — nothing will be written`);
|
|
551
|
-
await dryRunPreflight(config, manifest, opts.targetDatabaseUrl, storageTarget, alsoRestoringStorage, reader);
|
|
611
|
+
await dryRunPreflight(config, manifest, opts.targetDatabaseUrl, storageTarget, alsoRestoringStorage, reader, !!opts.skipAuth);
|
|
552
612
|
result.dryRun = true;
|
|
553
613
|
return result;
|
|
554
614
|
}
|
|
@@ -624,6 +684,12 @@ export async function runRestore(config, opts) {
|
|
|
624
684
|
throw new Error(`archive integrity check failed: downloaded sha256 ${sha256.slice(0, 12)}… ` +
|
|
625
685
|
`does not match manifest ${manifest.dump.sha256.slice(0, 12)}… — refusing to restore a corrupted dump`);
|
|
626
686
|
}
|
|
687
|
+
// 快照里有 Auth 用户:默认和数据库在同一个事务里写进去(auth-restore.ts)。写任何东西之前把 Auth 的
|
|
688
|
+
// 只读检查全部做完,过不了就停;读端不支持 auth.dump、或显式 --skip-auth 时按 2.9 的方式只恢复数据库
|
|
689
|
+
const authPlan = await planAuthRestore(manifest, reader, targetUrl, dumpPath, workdir, !!opts.skipAuth);
|
|
690
|
+
if (authPlan.result)
|
|
691
|
+
result.auth = authPlan.result;
|
|
692
|
+
const authArchive = authPlan.archive;
|
|
627
693
|
// 指向备份之外的外键(典型:profiles.id → auth.users),目标上缺被引用的行,恢复必然失败。
|
|
628
694
|
// 和 dry-run 同一份检查,在往目标写任何东西(连扩展都还没装)之前拦下,报错直接说缺什么、去哪补。
|
|
629
695
|
// 被引用的表也可能是待装的扩展建的:这种先记下,装完扩展再查一遍。
|
|
@@ -639,6 +705,8 @@ export async function runRestore(config, opts) {
|
|
|
639
705
|
targetUrl,
|
|
640
706
|
pendingExtensions: pending,
|
|
641
707
|
inTransaction: opts.inTransaction,
|
|
708
|
+
// 和数据库一起写进去的 Auth 表:指向它们的外键不再算"指向备份之外"
|
|
709
|
+
restoredTables: authArchive ? AUTH_TABLES : [],
|
|
642
710
|
});
|
|
643
711
|
const referenceProblems = logExternalReferences(references, manifest.database.schemas, false);
|
|
644
712
|
if (referenceProblems.length && opts.final) {
|
|
@@ -660,10 +728,29 @@ export async function runRestore(config, opts) {
|
|
|
660
728
|
// 一起回滚,目标原样不动(否则带配置表的扩展留下来,修好之后的重跑会被空目标门拦下,交叉审查复现)。
|
|
661
729
|
// 正式恢复(pg_restore)失败时装上的扩展留着:下一次运行照样要它们,空目标门也不数扩展自带的对象
|
|
662
730
|
// (配置表除外)。曾经在失败后删掉"本次新装的"扩展,交叉审查复现了它会误删别的连接同时装上的扩展。
|
|
663
|
-
|
|
731
|
+
const unavailableMessage = (unavailable) => `target cannot install extension(s): ${unavailable.join(", ")} — enable them in ` +
|
|
732
|
+
`the Supabase dashboard (Database → Extensions) and retry.`;
|
|
733
|
+
if (extensions.length && authArchive) {
|
|
734
|
+
// 带 Auth 的恢复把扩展装在恢复事务里(失败时一起回滚,重跑时目标是干净的)。这里先在一个最后回滚掉的
|
|
735
|
+
// 事务里试装一遍:装不上的、要等扩展装上才查得了的外键,在写任何东西之前拦下,目标原样不动
|
|
736
|
+
log.step(`Checking ${extensions.length} extension(s) can be installed on target…`);
|
|
737
|
+
const client = await connectPg(targetUrl);
|
|
738
|
+
try {
|
|
739
|
+
await client.query("begin");
|
|
740
|
+
const unavailable = await installExtensions(targetUrl, extensions, client);
|
|
741
|
+
if (unavailable.length)
|
|
742
|
+
throw new Error(unavailableMessage(unavailable));
|
|
743
|
+
if (firstCheck.waitingForExtensions || firstCheck.problems.length) {
|
|
744
|
+
await checkReferences([], { inTransaction: client, final: true });
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
finally {
|
|
748
|
+
await client.query("rollback").catch(() => { });
|
|
749
|
+
await client.end();
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
else if (extensions.length) {
|
|
664
753
|
log.step(`Installing ${extensions.length} extension(s) on target…`);
|
|
665
|
-
const unavailableMessage = (unavailable) => `target cannot install extension(s): ${unavailable.join(", ")} — enable them in ` +
|
|
666
|
-
`the Supabase dashboard (Database → Extensions) and retry.`;
|
|
667
754
|
if (firstCheck.waitingForExtensions || firstCheck.problems.length) {
|
|
668
755
|
const client = await connectPg(targetUrl);
|
|
669
756
|
try {
|
|
@@ -688,13 +775,92 @@ export async function runRestore(config, opts) {
|
|
|
688
775
|
throw new Error(unavailableMessage(unavailable));
|
|
689
776
|
}
|
|
690
777
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
778
|
+
const grantsToRestore = { schemas: manifest.database.schemas, recorded: manifest.database.grants };
|
|
779
|
+
let engine;
|
|
780
|
+
if (authArchive) {
|
|
781
|
+
log.step("Restoring the Auth users and the database into target in one transaction…");
|
|
782
|
+
const records = opts.restoreRecords;
|
|
783
|
+
const recordKey = restoreRecordKey(targetUrl);
|
|
784
|
+
let record = null;
|
|
785
|
+
// 提交之后再记进度:记不下只提醒,不能让已经提交的恢复因此报失败
|
|
786
|
+
const advance = async (phase) => {
|
|
787
|
+
if (!records || !record)
|
|
788
|
+
return;
|
|
789
|
+
record = { ...record, phase, updatedAt: new Date().toISOString() };
|
|
790
|
+
await records.save(recordKey, record).catch((error) => {
|
|
791
|
+
log.warn(`couldn't update the restore record (${error.message}); restore --status may be out of date`);
|
|
792
|
+
});
|
|
793
|
+
};
|
|
794
|
+
const run = await restoreWithAuth({
|
|
795
|
+
dumpPath,
|
|
796
|
+
archive: authArchive,
|
|
797
|
+
connString: targetUrl,
|
|
798
|
+
auth: manifest.auth,
|
|
799
|
+
schemas: manifest.database.schemas,
|
|
800
|
+
grants: grantsToRestore,
|
|
801
|
+
listDir: workdir,
|
|
802
|
+
extensions,
|
|
803
|
+
// 写 COMMIT 之前先记下来;记不下就不提交(抛错 → 回滚)
|
|
804
|
+
onTransactionId: async (xid, identity) => {
|
|
805
|
+
if (!records)
|
|
806
|
+
return;
|
|
807
|
+
const now = new Date().toISOString();
|
|
808
|
+
record = {
|
|
809
|
+
version: 1,
|
|
810
|
+
snapshot,
|
|
811
|
+
projectName: manifest.projectName,
|
|
812
|
+
dumpSha256: manifest.dump.sha256,
|
|
813
|
+
manifestSha256: createHash("sha256").update(rawManifest).digest("hex"),
|
|
814
|
+
target: describeTarget(targetUrl),
|
|
815
|
+
identity,
|
|
816
|
+
xid,
|
|
817
|
+
phase: "transaction",
|
|
818
|
+
startedAt: now,
|
|
819
|
+
updatedAt: now,
|
|
820
|
+
};
|
|
821
|
+
await records.save(recordKey, record);
|
|
822
|
+
},
|
|
823
|
+
onOutcome: (transaction) => transaction === "committed" ? advance("committed") : transaction === "rolled_back" ? advance("rolled_back") : undefined,
|
|
824
|
+
onGrantsApplied: () => advance("grants"),
|
|
825
|
+
});
|
|
826
|
+
if (run.transaction === "committed" && run.afterCommit.pass.failures.length === 0)
|
|
827
|
+
await advance("done");
|
|
828
|
+
if (run.transaction !== "committed") {
|
|
829
|
+
// 结果由事务本身说了算(没写 COMMIT,或 pg_xact_status 的回答),不再数 schema 里的对象去推断
|
|
830
|
+
throw new Error(authRestoreFailureMessage(run) + restoreFailureAdvice(run.failure ?? ""));
|
|
831
|
+
}
|
|
832
|
+
const committed = run.transaction === "committed";
|
|
833
|
+
const pass = committed ? run.afterCommit.pass : { expectedSkips: 0, failures: [run.failure] };
|
|
834
|
+
engine = {
|
|
835
|
+
preData: pass,
|
|
836
|
+
postData: { expectedSkips: 0, failures: [] },
|
|
837
|
+
ok: committed && pass.failures.length === 0,
|
|
838
|
+
orphanedForeignKeys: run.afterCommit?.orphaned,
|
|
839
|
+
grants: run.afterCommit?.grants,
|
|
840
|
+
// 和老路径一样,committed 只在提交之后的步骤出错时带上
|
|
841
|
+
...(pass.failures.length ? { committed: true } : {}),
|
|
842
|
+
};
|
|
843
|
+
if (committed) {
|
|
844
|
+
const { notes, manual } = authRestoreNotes(manifest.auth, manifest.database.schemas);
|
|
845
|
+
result.auth = {
|
|
846
|
+
restored: true,
|
|
847
|
+
users: manifest.auth.rows.users,
|
|
848
|
+
identities: manifest.auth.rows.identities,
|
|
849
|
+
triggers: run.triggers,
|
|
850
|
+
notes,
|
|
851
|
+
manual,
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
else {
|
|
856
|
+
log.step("Restoring database into target…");
|
|
857
|
+
engine = await restoreDatabaseArtifact({
|
|
858
|
+
dumpPath,
|
|
859
|
+
connString: targetUrl,
|
|
860
|
+
target: "supabase",
|
|
861
|
+
grants: grantsToRestore,
|
|
862
|
+
});
|
|
863
|
+
}
|
|
698
864
|
if (!engine.ok) {
|
|
699
865
|
const failures = [...engine.preData.failures, ...engine.postData.failures];
|
|
700
866
|
throw new Error(`database restore failed: ${failures.join(" | ")}.` +
|
|
@@ -728,6 +894,13 @@ export async function runRestore(config, opts) {
|
|
|
728
894
|
}
|
|
729
895
|
log.ok(`Database restored (${verified.tableCount} tables, ` +
|
|
730
896
|
`${verified.rowTotal.toLocaleString()} rows)`);
|
|
897
|
+
if (result.auth?.restored) {
|
|
898
|
+
const a = result.auth;
|
|
899
|
+
log.ok(`Auth users restored: ${a.users.toLocaleString("en-US")} users (${a.identities.toLocaleString("en-US")} identities)` +
|
|
900
|
+
(a.triggers.length ? `; trigger(s) recreated: ${a.triggers.join(", ")}` : ""));
|
|
901
|
+
for (const note of [...a.notes, ...a.manual.map((m) => `The ${m}.`), AUTH_AFTER_RESTORE])
|
|
902
|
+
log.warn(note);
|
|
903
|
+
}
|
|
731
904
|
}
|
|
732
905
|
else {
|
|
733
906
|
log.warn("No database target (--database + BACKUPDRILL_TARGET_DATABASE_URL); skipping database restore.");
|
|
@@ -816,3 +989,144 @@ export async function runRestore(config, opts) {
|
|
|
816
989
|
await rm(workdir, { recursive: true, force: true }).catch(() => { });
|
|
817
990
|
}
|
|
818
991
|
}
|
|
992
|
+
/**
|
|
993
|
+
* restore --status:只读。读这台机器上对这个目标的恢复记录,核对目标还是那个库,再用事务号问它提交了没有
|
|
994
|
+
*/
|
|
995
|
+
export async function restoreStatus(opts) {
|
|
996
|
+
assertNoHostOverride(opts.targetDatabaseUrl);
|
|
997
|
+
const target = describeTarget(opts.targetDatabaseUrl);
|
|
998
|
+
const record = await opts.restoreRecords.load(restoreRecordKey(opts.targetDatabaseUrl));
|
|
999
|
+
if (!record) {
|
|
1000
|
+
return { target, recorded: false, next: "There's no record on this machine of a restore with Auth users into this target." };
|
|
1001
|
+
}
|
|
1002
|
+
const base = { target, recorded: true, snapshot: record.snapshot, xid: record.xid, phase: record.phase };
|
|
1003
|
+
let transaction = "unknown";
|
|
1004
|
+
let sameTarget = true;
|
|
1005
|
+
try {
|
|
1006
|
+
const client = await connectCancellable(opts.targetDatabaseUrl, AbortSignal.timeout(opts.timeoutMs ?? 20_000));
|
|
1007
|
+
try {
|
|
1008
|
+
const now = await targetIdentity(client);
|
|
1009
|
+
sameTarget =
|
|
1010
|
+
now.databaseOid === record.identity.databaseOid &&
|
|
1011
|
+
(now.systemIdentifier === null || record.identity.systemIdentifier === null || now.systemIdentifier === record.identity.systemIdentifier);
|
|
1012
|
+
if (sameTarget) {
|
|
1013
|
+
const res = await client.query("select pg_xact_status($1::xid8) as status", [record.xid]);
|
|
1014
|
+
const status = res.rows[0].status;
|
|
1015
|
+
if (status === "committed" || status === "aborted" || status === "in progress")
|
|
1016
|
+
transaction = status;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
finally {
|
|
1020
|
+
await client.end().catch(() => { });
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
catch {
|
|
1024
|
+
transaction = "unknown";
|
|
1025
|
+
}
|
|
1026
|
+
const next = !sameTarget
|
|
1027
|
+
? "This target isn't the database the record was written for (it was recreated, or the connection points elsewhere). Check it by hand."
|
|
1028
|
+
: transaction === "committed"
|
|
1029
|
+
? record.phase === "done"
|
|
1030
|
+
? "Nothing to do: the restore committed and every step after it finished."
|
|
1031
|
+
: "The restore committed, but the grants and foreign keys added after the commit may be missing. Run `backupdrill restore --finish` with the same settings."
|
|
1032
|
+
: transaction === "aborted"
|
|
1033
|
+
? "The restore was rolled back, so nothing from the snapshot is on the target. Run restore again."
|
|
1034
|
+
: transaction === "in progress"
|
|
1035
|
+
? "The restore transaction is still open on the target. Wait, then check again."
|
|
1036
|
+
: "The target can't say what happened to this transaction (it couldn't be reached, or the id is too old). Check whether auth.users holds the snapshot's users and the restored schemas hold its tables.";
|
|
1037
|
+
return { ...base, transaction, next };
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* restore --finish:只做提交之后的步骤(补授权、补外键),和一次正常恢复用同一段代码、同一套规则(孤儿行建成
|
|
1041
|
+
* NOT VALID 等)。只对记录里"已提交、后面的步骤没做完"的那次恢复做;目标不是那个库就拒绝。可以重复执行:
|
|
1042
|
+
* 授权本来就是幂等的,已经加上的外键定义一样就跳过,不一样就停下报告
|
|
1043
|
+
*/
|
|
1044
|
+
export async function finishRestore(config, opts) {
|
|
1045
|
+
const targetUrl = opts.targetDatabaseUrl;
|
|
1046
|
+
assertNoHostOverride(targetUrl);
|
|
1047
|
+
const recordKey = restoreRecordKey(targetUrl);
|
|
1048
|
+
let record = await opts.restoreRecords.load(recordKey);
|
|
1049
|
+
if (!record)
|
|
1050
|
+
throw new Error("there's no record on this machine of a restore with Auth users into this target, so there's nothing to finish.");
|
|
1051
|
+
if (opts.snapshot && opts.snapshot !== record.snapshot) {
|
|
1052
|
+
throw new Error(`the restore on record is of snapshot ${record.snapshot}, not ${opts.snapshot}.`);
|
|
1053
|
+
}
|
|
1054
|
+
if (record.phase === "done") {
|
|
1055
|
+
throw new Error("nothing to finish: that restore committed and every step after it already finished.");
|
|
1056
|
+
}
|
|
1057
|
+
if (!record.manifestSha256) {
|
|
1058
|
+
throw new Error("this restore record was written by a pre-release build and doesn't say which manifest it used, so --finish " +
|
|
1059
|
+
"won't use it. Run restore --status to see whether that restore committed.");
|
|
1060
|
+
}
|
|
1061
|
+
const outcome = await transactionOutcome(targetUrl, record.xid, { identity: record.identity, waitMs: 5000 });
|
|
1062
|
+
if (outcome !== "committed") {
|
|
1063
|
+
throw new Error(outcome === "rolled_back"
|
|
1064
|
+
? "that restore was rolled back, so there's nothing to finish: run restore again."
|
|
1065
|
+
: "the target can't confirm that restore committed (it may be a different database now, or the transaction is still open); run restore --status.");
|
|
1066
|
+
}
|
|
1067
|
+
assertConfirmedTarget(opts.confirmTarget, targetUrl);
|
|
1068
|
+
const store = opts.store ?? s3SnapshotStore(config);
|
|
1069
|
+
const reader = await store.openSnapshot(record.snapshot);
|
|
1070
|
+
const rawManifest = await reader.readManifest();
|
|
1071
|
+
const manifest = parseManifest(rawManifest);
|
|
1072
|
+
// 快照名只是时间戳:核对这就是当初恢复的那一份(同一个项目、同一个 dump、一字不差的 manifest),
|
|
1073
|
+
// 不然授权和外键会照别的快照、或被改过的 manifest 改
|
|
1074
|
+
if (manifest.projectName !== record.projectName ||
|
|
1075
|
+
manifest.dump.sha256 !== record.dumpSha256 ||
|
|
1076
|
+
createHash("sha256").update(rawManifest).digest("hex") !== record.manifestSha256) {
|
|
1077
|
+
throw new Error(`snapshot ${record.snapshot} here isn't the one that was restored (project ${record.projectName}, dump ` +
|
|
1078
|
+
`${record.dumpSha256.slice(0, 12)}…): point restore --finish at the same bucket and project as the restore.`);
|
|
1079
|
+
}
|
|
1080
|
+
const workdir = await mkdtemp(join(tmpdir(), "backupdrill-finish-"));
|
|
1081
|
+
const save = async (phase) => {
|
|
1082
|
+
record = { ...record, phase, updatedAt: new Date().toISOString() };
|
|
1083
|
+
await opts.restoreRecords.save(recordKey, record).catch((error) => {
|
|
1084
|
+
log.warn(`couldn't update the restore record (${error.message})`);
|
|
1085
|
+
});
|
|
1086
|
+
};
|
|
1087
|
+
try {
|
|
1088
|
+
log.step("Downloading dump…");
|
|
1089
|
+
const dumpPath = join(workdir, "dump.pgcustom");
|
|
1090
|
+
const { sha256 } = await reader.downloadDump(manifest, dumpPath);
|
|
1091
|
+
if (sha256 !== manifest.dump.sha256) {
|
|
1092
|
+
throw new Error(`archive integrity check failed: downloaded sha256 ${sha256.slice(0, 12)}… does not match the manifest`);
|
|
1093
|
+
}
|
|
1094
|
+
log.step("Finishing the steps after the commit: grants, then foreign keys…");
|
|
1095
|
+
const deferred = await deferredForeignKeysOf(dumpPath, workdir, AUTH_TABLE_KEYS);
|
|
1096
|
+
const after = await afterCommit(targetUrl, { schemas: manifest.database.schemas, recorded: manifest.database.grants }, deferred, { resume: true, onGrantsApplied: () => save("grants") });
|
|
1097
|
+
if (after.pass.failures.length) {
|
|
1098
|
+
throw new Error(`finishing the restore failed: ${after.pass.failures.join(" | ")}. Run restore --finish again once the cause is fixed.`);
|
|
1099
|
+
}
|
|
1100
|
+
await save("done");
|
|
1101
|
+
const result = { snapshot: record.snapshot, restoredToDatabase: true, storageFilesWritten: 0 };
|
|
1102
|
+
log.step("Verifying restored tables…");
|
|
1103
|
+
const verified = await verifyRestored(targetUrl, manifest, dumpPath);
|
|
1104
|
+
result.databaseChecks = verified.checks;
|
|
1105
|
+
if (after.grants)
|
|
1106
|
+
result.databaseChecks.push(grantsCheck(after.grants, "restore"));
|
|
1107
|
+
if (after.orphaned?.length) {
|
|
1108
|
+
result.orphanedForeignKeys = after.orphaned;
|
|
1109
|
+
result.databaseChecks.push(orphanedForeignKeysCheck(after.orphaned));
|
|
1110
|
+
}
|
|
1111
|
+
result.databaseVerified = result.databaseChecks.every((c) => c.pass);
|
|
1112
|
+
for (const check of result.databaseChecks)
|
|
1113
|
+
(check.pass ? log.ok : log.warn)(`${check.name}: ${check.detail}`);
|
|
1114
|
+
// 只有带 Auth 的单事务恢复才写恢复记录:能接着做,就说明 Auth 用户已经随那次提交写进了目标。
|
|
1115
|
+
// 结果里照实带上(和一次做完的恢复一样),调用方的报告才不会说"Auth 用户没恢复"
|
|
1116
|
+
if (manifest.auth?.status === "included" && manifest.auth.rows) {
|
|
1117
|
+
const { notes, manual } = authRestoreNotes(manifest.auth, manifest.database.schemas);
|
|
1118
|
+
result.auth = {
|
|
1119
|
+
restored: true,
|
|
1120
|
+
users: manifest.auth.rows.users,
|
|
1121
|
+
identities: manifest.auth.rows.identities,
|
|
1122
|
+
notes,
|
|
1123
|
+
manual,
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
log.ok("The restore is finished.");
|
|
1127
|
+
return result;
|
|
1128
|
+
}
|
|
1129
|
+
finally {
|
|
1130
|
+
await rm(workdir, { recursive: true, force: true }).catch(() => { });
|
|
1131
|
+
}
|
|
1132
|
+
}
|
package/dist/snapshot-store.d.ts
CHANGED
|
@@ -34,6 +34,12 @@ export interface SnapshotWriter {
|
|
|
34
34
|
describe(file: string): string;
|
|
35
35
|
/** relationBytes = 要转储的表的磁盘占用(量不出为 null),实现可据此决定分块 */
|
|
36
36
|
uploadDump(body: Readable, relationBytes: number | null): DumpUpload;
|
|
37
|
+
/**
|
|
38
|
+
* 可选(2.10.0 起):Auth 用户归档 auth.dump 写到哪、记进 manifest.auth.dump.key 的值。
|
|
39
|
+
* 没实现的存储(例如还没适配的托管目标)备份时自动跳过 Auth,其余行为不变。
|
|
40
|
+
*/
|
|
41
|
+
readonly authDumpKey?: string;
|
|
42
|
+
uploadAuthDump?(body: Readable): DumpUpload;
|
|
37
43
|
/** RECOVERY.md 写的是"从这个位置怎么恢复",所以由各实现自己渲染 */
|
|
38
44
|
writeRecoveryDoc(manifest: Manifest): Promise<void>;
|
|
39
45
|
/** manifest 是快照的"完成标记",调用方保证最后写 */
|
|
@@ -47,6 +53,13 @@ export interface SnapshotReader {
|
|
|
47
53
|
bytes: number;
|
|
48
54
|
sha256: string;
|
|
49
55
|
}>;
|
|
56
|
+
/** 可选(2.10.0 起):下载 auth.dump。没实现时,带 Auth 的快照按不带 Auth 处理 */
|
|
57
|
+
downloadAuthDump?(manifest: Manifest, dest: string, opts?: {
|
|
58
|
+
signal?: AbortSignal;
|
|
59
|
+
}): Promise<{
|
|
60
|
+
bytes: number;
|
|
61
|
+
sha256: string;
|
|
62
|
+
}>;
|
|
50
63
|
/** 这份快照的 Storage 文件从哪读;实现不支持 Storage 文件时为 null */
|
|
51
64
|
storageFiles(manifest: Manifest): StorageFilesLocation | null;
|
|
52
65
|
}
|
package/dist/snapshot-store.js
CHANGED
|
@@ -38,6 +38,25 @@ export function s3SnapshotStore(config) {
|
|
|
38
38
|
abort: () => upload.abort(),
|
|
39
39
|
};
|
|
40
40
|
},
|
|
41
|
+
authDumpKey: `${base}/auth.dump`,
|
|
42
|
+
uploadAuthDump(body) {
|
|
43
|
+
// 两张表通常几 MB;分片用保底大小即可(上限 2 GiB,见 AUTH_DUMP_MAX_BYTES)
|
|
44
|
+
const upload = new Upload({
|
|
45
|
+
client: s3(),
|
|
46
|
+
partSize: dumpPartSizeFor(null),
|
|
47
|
+
params: {
|
|
48
|
+
Bucket: storage.bucket,
|
|
49
|
+
Key: `${base}/auth.dump`,
|
|
50
|
+
Body: body,
|
|
51
|
+
ContentType: "application/octet-stream",
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
done: upload.done().then(() => { }),
|
|
56
|
+
// 只中止没完成的分片上传;不去删已经写完的对象(我们从不删用户桶里的对象)
|
|
57
|
+
abort: () => upload.abort(),
|
|
58
|
+
};
|
|
59
|
+
},
|
|
41
60
|
async writeRecoveryDoc(manifest) {
|
|
42
61
|
await s3().send(new PutObjectCommand({
|
|
43
62
|
Bucket: storage.bucket,
|
|
@@ -69,6 +88,12 @@ export function s3SnapshotStore(config) {
|
|
|
69
88
|
name: prefix.replace(/\/$/, "").split("/").pop(),
|
|
70
89
|
readManifest: () => getObjectText(s3(), storage.bucket, `${prefix}manifest.json`),
|
|
71
90
|
downloadDump: (manifest, dest) => downloadToFile(s3(), storage.bucket, manifest.dump.key, dest),
|
|
91
|
+
downloadAuthDump: (manifest, dest, opts) => {
|
|
92
|
+
if (manifest.auth?.status !== "included" || !manifest.auth.dump) {
|
|
93
|
+
throw new Error("this snapshot has no Auth archive");
|
|
94
|
+
}
|
|
95
|
+
return downloadToFile(s3(), storage.bucket, manifest.auth.dump.key, dest, { signal: opts?.signal });
|
|
96
|
+
},
|
|
72
97
|
storageFiles: (manifest) => ({ s3: s3(), bucket: storage.bucket, base: storageBaseOf(manifest) }),
|
|
73
98
|
};
|
|
74
99
|
},
|
package/dist/snapshots.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export declare function writeFully(fh: WritableHandle, chunk: Buffer, position:
|
|
|
41
41
|
export declare function downloadToFile(s3: S3Client, bucket: string, key: string, dest: string, opts?: {
|
|
42
42
|
maxAttempts?: number;
|
|
43
43
|
openFile?: (path: string) => Promise<WritableHandle>;
|
|
44
|
+
/** 可选:调用方叫停时中止请求和写盘、不再重试(Auth 附加校验用;不传时行为与之前一致) */
|
|
45
|
+
signal?: AbortSignal;
|
|
44
46
|
}): Promise<{
|
|
45
47
|
bytes: number;
|
|
46
48
|
sha256: string;
|
package/dist/snapshots.js
CHANGED
|
@@ -134,11 +134,14 @@ export async function downloadToFile(s3, bucket, key, dest, opts = {}) {
|
|
|
134
134
|
await inFlight.catch(() => { });
|
|
135
135
|
const from = written; // 本次请求的起点在发请求前冻结,后面的判断都用它
|
|
136
136
|
try {
|
|
137
|
-
|
|
137
|
+
if (opts.signal?.aborted)
|
|
138
|
+
throw new NonRetryableDownloadError("download stopped by the caller");
|
|
139
|
+
const command = new GetObjectCommand({
|
|
138
140
|
Bucket: bucket,
|
|
139
141
|
Key: key,
|
|
140
142
|
...(from > 0 ? { Range: `bytes=${from}-` } : {}),
|
|
141
|
-
})
|
|
143
|
+
});
|
|
144
|
+
const res = opts.signal ? await s3.send(command, { abortSignal: opts.signal }) : await s3.send(command);
|
|
142
145
|
const body = res.Body;
|
|
143
146
|
const status = res.$metadata.httpStatusCode;
|
|
144
147
|
if (from > 0 && status !== 206) {
|
|
@@ -174,7 +177,10 @@ export async function downloadToFile(s3, bucket, key, dest, opts = {}) {
|
|
|
174
177
|
});
|
|
175
178
|
},
|
|
176
179
|
});
|
|
177
|
-
|
|
180
|
+
if (opts.signal)
|
|
181
|
+
await pipeline(body, sink, { signal: opts.signal });
|
|
182
|
+
else
|
|
183
|
+
await pipeline(body, sink);
|
|
178
184
|
await inFlight.catch(() => { });
|
|
179
185
|
if (total !== null && written !== total) {
|
|
180
186
|
// 流"正常"结束但字节不够:对端掐断时 Node 有时不报错只是提前 end
|
|
@@ -184,6 +190,7 @@ export async function downloadToFile(s3, bucket, key, dest, opts = {}) {
|
|
|
184
190
|
}
|
|
185
191
|
catch (error) {
|
|
186
192
|
if (error instanceof NonRetryableDownloadError ||
|
|
193
|
+
opts.signal?.aborted ||
|
|
187
194
|
!isRetryableDownloadError(error) ||
|
|
188
195
|
attempt >= maxAttempts) {
|
|
189
196
|
throw error;
|
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.
|
|
10
|
+
The agent runs every command as `npx -y backupdrill@2.10.0`, so the CLI version stays fixed.
|
|
11
11
|
|
|
12
12
|
## What you need
|
|
13
13
|
|