@prenta/cli 0.16.5 → 0.17.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.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +33 -24
- package/CHANGELOG.md +6 -0
- package/dist/backup/blob-store.d.ts +89 -0
- package/dist/backup/blob-store.d.ts.map +1 -0
- package/dist/backup/blob-store.js +183 -0
- package/dist/backup/blob-store.js.map +1 -0
- package/dist/backup/common.d.ts +68 -0
- package/dist/backup/common.d.ts.map +1 -0
- package/dist/backup/common.js +127 -0
- package/dist/backup/common.js.map +1 -0
- package/dist/backup/crypto.d.ts +26 -0
- package/dist/backup/crypto.d.ts.map +1 -0
- package/dist/backup/crypto.js +175 -0
- package/dist/backup/crypto.js.map +1 -0
- package/dist/backup/manifest.d.ts +69 -0
- package/dist/backup/manifest.d.ts.map +1 -0
- package/dist/backup/manifest.js +161 -0
- package/dist/backup/manifest.js.map +1 -0
- package/dist/backup/pg-tools.d.ts +74 -0
- package/dist/backup/pg-tools.d.ts.map +1 -0
- package/dist/backup/pg-tools.js +267 -0
- package/dist/backup/pg-tools.js.map +1 -0
- package/dist/backup/workflow-template.d.ts +14 -0
- package/dist/backup/workflow-template.d.ts.map +1 -0
- package/dist/backup/workflow-template.js +49 -0
- package/dist/backup/workflow-template.js.map +1 -0
- package/dist/commands/db-backup.d.ts +56 -0
- package/dist/commands/db-backup.d.ts.map +1 -0
- package/dist/commands/db-backup.js +226 -0
- package/dist/commands/db-backup.js.map +1 -0
- package/dist/commands/db-restore.d.ts +70 -0
- package/dist/commands/db-restore.d.ts.map +1 -0
- package/dist/commands/db-restore.js +380 -0
- package/dist/commands/db-restore.js.map +1 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +6 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/deployment/diagnostics.d.ts +4 -0
- package/dist/deployment/diagnostics.d.ts.map +1 -1
- package/dist/deployment/diagnostics.js +27 -0
- package/dist/deployment/diagnostics.js.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/repo-root.d.ts +9 -0
- package/dist/utils/repo-root.d.ts.map +1 -0
- package/dist/utils/repo-root.js +21 -0
- package/dist/utils/repo-root.js.map +1 -0
- package/package.json +10 -3
- package/src/__tests__/backup-blob-store.test.ts +324 -0
- package/src/__tests__/backup-common.test.ts +103 -0
- package/src/__tests__/backup-crypto.test.ts +197 -0
- package/src/__tests__/backup-manifest.test.ts +189 -0
- package/src/__tests__/backup-pg-tools.test.ts +275 -0
- package/src/__tests__/db-backup.test.ts +557 -0
- package/src/__tests__/db-restore.test.ts +784 -0
- package/src/__tests__/deployment-diagnostics.test.ts +55 -0
- package/src/__tests__/fixtures/fake-blob.ts +120 -0
- package/src/__tests__/fixtures/fake-spawn.ts +66 -0
- package/src/__tests__/fixtures/pg-url.ts +56 -0
- package/src/__tests__/integration/backup-roundtrip.int.test.ts +208 -0
- package/src/__tests__/repo-root.test.ts +49 -0
- package/src/backup/blob-store.ts +294 -0
- package/src/backup/common.ts +153 -0
- package/src/backup/crypto.ts +192 -0
- package/src/backup/manifest.ts +217 -0
- package/src/backup/pg-tools.ts +384 -0
- package/src/backup/workflow-template.ts +49 -0
- package/src/commands/db-backup.ts +335 -0
- package/src/commands/db-restore.ts +542 -0
- package/src/commands/doctor.ts +6 -0
- package/src/deployment/diagnostics.ts +42 -0
- package/src/index.ts +4 -0
- package/src/utils/repo-root.ts +19 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const BACKUP_MAGIC: Buffer;
|
|
2
|
+
export declare const IV_LENGTH = 12;
|
|
3
|
+
export declare const TAG_LENGTH = 16;
|
|
4
|
+
export declare const KEY_LENGTH = 32;
|
|
5
|
+
export declare class BackupKeyError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Parse `BACKUP_ENCRYPTION_KEY`. Throws `BackupKeyError` with an actionable
|
|
10
|
+
* message when the value is missing or is not exactly 64 hex characters.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseBackupKey(hex: string | undefined): Buffer;
|
|
13
|
+
/**
|
|
14
|
+
* Encrypt `src` into `dest`. Returns the number of bytes written (header +
|
|
15
|
+
* ciphertext + tag). `dest` is truncated if it already exists.
|
|
16
|
+
*/
|
|
17
|
+
export declare function encryptFile(src: string, dest: string, key: Buffer): Promise<{
|
|
18
|
+
bytesWritten: number;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Decrypt `src` into `dest`, verifying the GCM auth tag. Throws when the
|
|
22
|
+
* file is not a Prenta envelope, or when the key is wrong / the ciphertext or
|
|
23
|
+
* tag were modified ("authentication failed"). On failure `dest` is removed.
|
|
24
|
+
*/
|
|
25
|
+
export declare function decryptFile(src: string, dest: string, key: Buffer): Promise<void>;
|
|
26
|
+
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/backup/crypto.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,YAAY,EAAE,MAAwC,CAAA;AACnE,eAAO,MAAM,SAAS,KAAK,CAAA;AAC3B,eAAO,MAAM,UAAU,KAAK,CAAA;AAC5B,eAAO,MAAM,UAAU,KAAK,CAAA;AAI5B,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAa9D;AA4CD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAanC;AA6BD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BvF"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AES-256-GCM file envelope for encrypted database dumps.
|
|
3
|
+
*
|
|
4
|
+
* Layout (spec 2026-09-18-db-backups-and-dr-design.md §1 step 4):
|
|
5
|
+
*
|
|
6
|
+
* `PRENTA1` magic (7 bytes) | IV (12 bytes) | ciphertext | auth tag (16 bytes)
|
|
7
|
+
*
|
|
8
|
+
* The key is `BACKUP_ENCRYPTION_KEY`: 32 bytes as 64 hex characters, distinct
|
|
9
|
+
* from `CMS_ENCRYPTION_KEY`. Encryption and decryption stream through Node's
|
|
10
|
+
* `crypto` so a multi-gigabyte dump never has to fit in memory. Decryption
|
|
11
|
+
* verifies the GCM tag before the output is considered valid; on any failure
|
|
12
|
+
* the partial output file is removed so a corrupt plaintext can never be
|
|
13
|
+
* mistaken for a good restore source.
|
|
14
|
+
*/
|
|
15
|
+
import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto';
|
|
16
|
+
import { createReadStream, createWriteStream } from 'node:fs';
|
|
17
|
+
import { open, rm, stat } from 'node:fs/promises';
|
|
18
|
+
import { Readable, Transform } from 'node:stream';
|
|
19
|
+
import { pipeline } from 'node:stream/promises';
|
|
20
|
+
export const BACKUP_MAGIC = Buffer.from('PRENTA1', 'ascii');
|
|
21
|
+
export const IV_LENGTH = 12;
|
|
22
|
+
export const TAG_LENGTH = 16;
|
|
23
|
+
export const KEY_LENGTH = 32;
|
|
24
|
+
const ALGORITHM = 'aes-256-gcm';
|
|
25
|
+
const HEADER_LENGTH = BACKUP_MAGIC.length + IV_LENGTH;
|
|
26
|
+
export class BackupKeyError extends Error {
|
|
27
|
+
constructor(message) {
|
|
28
|
+
super(message);
|
|
29
|
+
this.name = 'BackupKeyError';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Parse `BACKUP_ENCRYPTION_KEY`. Throws `BackupKeyError` with an actionable
|
|
34
|
+
* message when the value is missing or is not exactly 64 hex characters.
|
|
35
|
+
*/
|
|
36
|
+
export function parseBackupKey(hex) {
|
|
37
|
+
const value = hex?.trim() ?? '';
|
|
38
|
+
if (!value) {
|
|
39
|
+
throw new BackupKeyError('BACKUP_ENCRYPTION_KEY is not set. Generate one with `openssl rand -hex 32` and escrow it — backups cannot be decrypted without it.');
|
|
40
|
+
}
|
|
41
|
+
if (!/^[0-9a-fA-F]{64}$/.test(value)) {
|
|
42
|
+
throw new BackupKeyError(`BACKUP_ENCRYPTION_KEY must be exactly 64 hex characters (32 bytes); got ${value.length} characters.`);
|
|
43
|
+
}
|
|
44
|
+
return Buffer.from(value, 'hex');
|
|
45
|
+
}
|
|
46
|
+
function assertKey(key) {
|
|
47
|
+
if (key.length !== KEY_LENGTH) {
|
|
48
|
+
throw new BackupKeyError(`Backup key must be ${KEY_LENGTH} bytes; got ${key.length}.`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Emits header + ciphertext, then the auth tag on flush. */
|
|
52
|
+
class GcmEncryptStream extends Transform {
|
|
53
|
+
cipher;
|
|
54
|
+
header;
|
|
55
|
+
headerSent = false;
|
|
56
|
+
constructor(cipher, header) {
|
|
57
|
+
super();
|
|
58
|
+
this.cipher = cipher;
|
|
59
|
+
this.header = header;
|
|
60
|
+
}
|
|
61
|
+
sendHeader() {
|
|
62
|
+
if (!this.headerSent) {
|
|
63
|
+
this.headerSent = true;
|
|
64
|
+
this.push(this.header);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
_transform(chunk, _encoding, cb) {
|
|
68
|
+
this.sendHeader();
|
|
69
|
+
cb(null, this.cipher.update(chunk));
|
|
70
|
+
}
|
|
71
|
+
_flush(cb) {
|
|
72
|
+
this.sendHeader();
|
|
73
|
+
try {
|
|
74
|
+
const last = this.cipher.final();
|
|
75
|
+
if (last.length > 0)
|
|
76
|
+
this.push(last);
|
|
77
|
+
this.push(this.cipher.getAuthTag());
|
|
78
|
+
cb();
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
cb(err instanceof Error ? err : new Error(String(err)));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Encrypt `src` into `dest`. Returns the number of bytes written (header +
|
|
87
|
+
* ciphertext + tag). `dest` is truncated if it already exists.
|
|
88
|
+
*/
|
|
89
|
+
export async function encryptFile(src, dest, key) {
|
|
90
|
+
assertKey(key);
|
|
91
|
+
const iv = randomBytes(IV_LENGTH);
|
|
92
|
+
const cipher = createCipheriv(ALGORITHM, key, iv, { authTagLength: TAG_LENGTH });
|
|
93
|
+
const header = Buffer.concat([BACKUP_MAGIC, iv]);
|
|
94
|
+
const out = createWriteStream(dest);
|
|
95
|
+
try {
|
|
96
|
+
await pipeline(createReadStream(src), new GcmEncryptStream(cipher, header), out);
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
await rm(dest, { force: true });
|
|
100
|
+
throw err;
|
|
101
|
+
}
|
|
102
|
+
return { bytesWritten: out.bytesWritten };
|
|
103
|
+
}
|
|
104
|
+
class BackupFormatError extends Error {
|
|
105
|
+
constructor(message) {
|
|
106
|
+
super(message);
|
|
107
|
+
this.name = 'BackupFormatError';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function readEnvelope(src) {
|
|
111
|
+
const { size } = await stat(src);
|
|
112
|
+
if (size < HEADER_LENGTH + TAG_LENGTH) {
|
|
113
|
+
throw new BackupFormatError(`${src} is not a Prenta backup (file too short).`);
|
|
114
|
+
}
|
|
115
|
+
const handle = await open(src, 'r');
|
|
116
|
+
try {
|
|
117
|
+
const header = Buffer.alloc(HEADER_LENGTH);
|
|
118
|
+
await handle.read(header, 0, HEADER_LENGTH, 0);
|
|
119
|
+
if (!header.subarray(0, BACKUP_MAGIC.length).equals(BACKUP_MAGIC)) {
|
|
120
|
+
throw new BackupFormatError(`${src} is not a Prenta backup (missing PRENTA1 magic).`);
|
|
121
|
+
}
|
|
122
|
+
const tag = Buffer.alloc(TAG_LENGTH);
|
|
123
|
+
await handle.read(tag, 0, TAG_LENGTH, size - TAG_LENGTH);
|
|
124
|
+
return { iv: header.subarray(BACKUP_MAGIC.length), tag, size };
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
await handle.close();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Decrypt `src` into `dest`, verifying the GCM auth tag. Throws when the
|
|
132
|
+
* file is not a Prenta envelope, or when the key is wrong / the ciphertext or
|
|
133
|
+
* tag were modified ("authentication failed"). On failure `dest` is removed.
|
|
134
|
+
*/
|
|
135
|
+
export async function decryptFile(src, dest, key) {
|
|
136
|
+
assertKey(key);
|
|
137
|
+
const { iv, tag, size } = await readEnvelope(src);
|
|
138
|
+
const decipher = createDecipheriv(ALGORITHM, key, iv, { authTagLength: TAG_LENGTH });
|
|
139
|
+
decipher.setAuthTag(tag);
|
|
140
|
+
// `end` is inclusive; an empty plaintext has no ciphertext bytes at all.
|
|
141
|
+
const ciphertextEnd = size - TAG_LENGTH - 1;
|
|
142
|
+
const input = ciphertextEnd < HEADER_LENGTH
|
|
143
|
+
? Readable.from([])
|
|
144
|
+
: createReadStream(src, { start: HEADER_LENGTH, end: ciphertextEnd });
|
|
145
|
+
try {
|
|
146
|
+
await pipeline(input, decipher, createWriteStream(dest));
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
try {
|
|
150
|
+
await rm(dest, { force: true });
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
// The original error is what the operator needs; a failed cleanup must not mask it.
|
|
154
|
+
}
|
|
155
|
+
if (isGcmAuthError(err)) {
|
|
156
|
+
throw new Error(`Backup authentication failed for ${src}: wrong BACKUP_ENCRYPTION_KEY or the file was modified.`);
|
|
157
|
+
}
|
|
158
|
+
throw err;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Node reports a GCM tag mismatch as "Unsupported state or unable to
|
|
163
|
+
* authenticate data" (OpenSSL codes `ERR_OSSL_*` on newer releases). Matched
|
|
164
|
+
* precisely so an unrelated error whose text happens to contain "auth" (a
|
|
165
|
+
* path, an ENOENT) is not reported as a wrong key.
|
|
166
|
+
*/
|
|
167
|
+
function isGcmAuthError(err) {
|
|
168
|
+
if (!(err instanceof Error))
|
|
169
|
+
return false;
|
|
170
|
+
const code = err.code;
|
|
171
|
+
if (typeof code === 'string' && code.startsWith('ERR_OSSL_'))
|
|
172
|
+
return true;
|
|
173
|
+
return /Unsupported state or unable to authenticate data/i.test(err.message);
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/backup/crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAA;AAC3F,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC7D,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAA;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,MAAM,CAAC,MAAM,YAAY,GAAW,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AACnE,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,CAAA;AAC3B,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAA;AAC5B,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAA;AAC5B,MAAM,SAAS,GAAG,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,CAAC;QAAC,MAAM,CAAC;YACP,oFAAoF;QACtF,CAAC;QACD,IAAI,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,oCAAoC,GAAG,yDAAyD,CACjG,CAAA;QACH,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CAAC,GAAY;IAClC,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACzC,MAAM,IAAI,GAAI,GAA6B,CAAC,IAAI,CAAA;IAChD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QAAE,OAAO,IAAI,CAAA;IACzE,OAAO,mDAAmD,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;AAC9E,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export declare const MANIFEST_VERSION = 1;
|
|
2
|
+
export declare const DUMP_EXTENSION = ".dump.enc";
|
|
3
|
+
export declare const MANIFEST_EXTENSION = ".manifest.json";
|
|
4
|
+
export interface BackupTableRows {
|
|
5
|
+
schema: string;
|
|
6
|
+
name: string;
|
|
7
|
+
rows: number;
|
|
8
|
+
}
|
|
9
|
+
export interface BackupManifest {
|
|
10
|
+
version: typeof MANIFEST_VERSION;
|
|
11
|
+
/** ISO-8601 instant the dump started. */
|
|
12
|
+
createdAt: string;
|
|
13
|
+
/** `YYYY-MM-DDTHHmmssZ` — shared by the `.dump.enc` and `.manifest.json` names. */
|
|
14
|
+
stamp: string;
|
|
15
|
+
database: {
|
|
16
|
+
host: string;
|
|
17
|
+
name: string;
|
|
18
|
+
};
|
|
19
|
+
pgDumpVersion: string;
|
|
20
|
+
/** Size of the encrypted `.dump.enc` file. */
|
|
21
|
+
sizeBytes: number;
|
|
22
|
+
/** SHA-256 (hex) of the encrypted `.dump.enc` file. */
|
|
23
|
+
sha256: string;
|
|
24
|
+
/** Source of `tables[].rows`; always the planner estimate today. */
|
|
25
|
+
rowCounts: 'estimate';
|
|
26
|
+
tables: BackupTableRows[];
|
|
27
|
+
}
|
|
28
|
+
/** `YYYY-MM-DDTHHmmssZ` for a UTC instant. */
|
|
29
|
+
export declare function stampFor(date: Date): string;
|
|
30
|
+
/** Extract the stamp from a dump/manifest pathname (or a bare stamp). */
|
|
31
|
+
export declare function parseStamp(pathname: string): string | null;
|
|
32
|
+
/** Parse a stamp back into the UTC instant it encodes. */
|
|
33
|
+
export declare function stampToDate(stamp: string): Date;
|
|
34
|
+
/** Chronological comparator for stamps (fixed-width, so lexical works). */
|
|
35
|
+
export declare function compareStamps(a: string, b: string): number;
|
|
36
|
+
/**
|
|
37
|
+
* True when `stamp` is strictly older than `days` before `now`. A backup
|
|
38
|
+
* exactly `days` old is kept (boundary day kept, day `days + 1` pruned).
|
|
39
|
+
* Non-positive or NaN retention never prunes.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isOlderThan(stamp: string, days: number, now: Date): boolean;
|
|
42
|
+
/** `<prefix>/<stamp>.dump.enc` — the pathname the blob store uses for the dump. */
|
|
43
|
+
export declare function dumpPathname(prefix: string, stamp: string): string;
|
|
44
|
+
/** Sibling `.manifest.json` pathname for a `.dump.enc` pathname. */
|
|
45
|
+
export declare function manifestPathnameFor(dumpPath: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Host + database name from a connection URL — never the credentials. The
|
|
48
|
+
* name is normalized like the production guard's (`normalizeDatabaseName`:
|
|
49
|
+
* empty path → `postgres`, trailing `/` dropped) so a prompt that shows this
|
|
50
|
+
* name accepts exactly what the guard compared.
|
|
51
|
+
*/
|
|
52
|
+
export declare function describeDatabase(url: string): {
|
|
53
|
+
host: string;
|
|
54
|
+
name: string;
|
|
55
|
+
};
|
|
56
|
+
/** Streaming SHA-256 of a file as lowercase hex. */
|
|
57
|
+
export declare function sha256File(filePath: string): Promise<string>;
|
|
58
|
+
export interface BuildManifestInput {
|
|
59
|
+
createdAt: Date;
|
|
60
|
+
databaseUrl: string;
|
|
61
|
+
pgDumpVersion: string;
|
|
62
|
+
sizeBytes: number;
|
|
63
|
+
sha256: string;
|
|
64
|
+
tables: BackupTableRows[];
|
|
65
|
+
}
|
|
66
|
+
export declare function buildManifest(input: BuildManifestInput): BackupManifest;
|
|
67
|
+
/** Validate untrusted JSON (downloaded manifest) into a `BackupManifest`. */
|
|
68
|
+
export declare function parseManifest(value: unknown): BackupManifest;
|
|
69
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/backup/manifest.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,gBAAgB,IAAI,CAAA;AACjC,eAAO,MAAM,cAAc,cAAc,CAAA;AACzC,eAAO,MAAM,kBAAkB,mBAAmB,CAAA;AAElD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,gBAAgB,CAAA;IAChC,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB,mFAAmF;IACnF,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACxC,aAAa,EAAE,MAAM,CAAA;IACrB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAA;IACjB,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAA;IACd,oEAAoE;IACpE,SAAS,EAAE,UAAU,CAAA;IACrB,MAAM,EAAE,eAAe,EAAE,CAAA;CAC1B;AASD,8CAA8C;AAC9C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAK3C;AAED,yEAA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stamp helpers shared by `db:backup` and `db:restore`.
|
|
3
|
+
*
|
|
4
|
+
* Every backup is a pair of files named by one UTC stamp
|
|
5
|
+
* (`YYYY-MM-DDTHHmmssZ`): `<stamp>.dump.enc` (the encrypted pg_dump) and
|
|
6
|
+
* `<stamp>.manifest.json` (this module's `BackupManifest`). The stamp is the
|
|
7
|
+
* sort key for `latest` and the retention cut-off — it is fixed-width, so
|
|
8
|
+
* plain string comparison orders chronologically.
|
|
9
|
+
*
|
|
10
|
+
* Table row counts in the manifest come from `pg_class.reltuples` (planner
|
|
11
|
+
* estimates, no full scans); `rowCounts: 'estimate'` records that so the
|
|
12
|
+
* restore report compares like with like.
|
|
13
|
+
*/
|
|
14
|
+
import { createHash } from 'node:crypto';
|
|
15
|
+
import { createReadStream } from 'node:fs';
|
|
16
|
+
import { normalizeDatabaseName } from './common.js';
|
|
17
|
+
export const MANIFEST_VERSION = 1;
|
|
18
|
+
export const DUMP_EXTENSION = '.dump.enc';
|
|
19
|
+
export const MANIFEST_EXTENSION = '.manifest.json';
|
|
20
|
+
const STAMP_RE = /(\d{4}-\d{2}-\d{2}T\d{6}Z)/;
|
|
21
|
+
const STAMP_EXACT_RE = /^\d{4}-\d{2}-\d{2}T\d{6}Z$/;
|
|
22
|
+
function pad(n, width = 2) {
|
|
23
|
+
return String(n).padStart(width, '0');
|
|
24
|
+
}
|
|
25
|
+
/** `YYYY-MM-DDTHHmmssZ` for a UTC instant. */
|
|
26
|
+
export function stampFor(date) {
|
|
27
|
+
return (`${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}` +
|
|
28
|
+
`T${pad(date.getUTCHours())}${pad(date.getUTCMinutes())}${pad(date.getUTCSeconds())}Z`);
|
|
29
|
+
}
|
|
30
|
+
/** Extract the stamp from a dump/manifest pathname (or a bare stamp). */
|
|
31
|
+
export function parseStamp(pathname) {
|
|
32
|
+
const base = pathname.split(/[\\/]/).pop() ?? '';
|
|
33
|
+
const match = base.match(STAMP_RE);
|
|
34
|
+
if (!match?.[1])
|
|
35
|
+
return null;
|
|
36
|
+
const stamp = match[1];
|
|
37
|
+
if (!STAMP_EXACT_RE.test(stamp))
|
|
38
|
+
return null;
|
|
39
|
+
return Number.isNaN(stampToDate(stamp).getTime()) ? null : stamp;
|
|
40
|
+
}
|
|
41
|
+
/** Parse a stamp back into the UTC instant it encodes. */
|
|
42
|
+
export function stampToDate(stamp) {
|
|
43
|
+
const m = stamp.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2})(\d{2})(\d{2})Z$/);
|
|
44
|
+
if (!m)
|
|
45
|
+
return new Date(Number.NaN);
|
|
46
|
+
return new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3]), Number(m[4]), Number(m[5]), Number(m[6])));
|
|
47
|
+
}
|
|
48
|
+
/** Chronological comparator for stamps (fixed-width, so lexical works). */
|
|
49
|
+
export function compareStamps(a, b) {
|
|
50
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* True when `stamp` is strictly older than `days` before `now`. A backup
|
|
54
|
+
* exactly `days` old is kept (boundary day kept, day `days + 1` pruned).
|
|
55
|
+
* Non-positive or NaN retention never prunes.
|
|
56
|
+
*/
|
|
57
|
+
export function isOlderThan(stamp, days, now) {
|
|
58
|
+
if (!Number.isFinite(days) || days <= 0)
|
|
59
|
+
return false;
|
|
60
|
+
const at = stampToDate(stamp).getTime();
|
|
61
|
+
if (Number.isNaN(at))
|
|
62
|
+
return false;
|
|
63
|
+
const cutoff = now.getTime() - days * 86_400_000;
|
|
64
|
+
return at < cutoff;
|
|
65
|
+
}
|
|
66
|
+
/** `<prefix>/<stamp>.dump.enc` — the pathname the blob store uses for the dump. */
|
|
67
|
+
export function dumpPathname(prefix, stamp) {
|
|
68
|
+
return `${prefix.replace(/\/+$/, '')}/${stamp}${DUMP_EXTENSION}`;
|
|
69
|
+
}
|
|
70
|
+
/** Sibling `.manifest.json` pathname for a `.dump.enc` pathname. */
|
|
71
|
+
export function manifestPathnameFor(dumpPath) {
|
|
72
|
+
return dumpPath.endsWith(DUMP_EXTENSION)
|
|
73
|
+
? dumpPath.slice(0, -DUMP_EXTENSION.length) + MANIFEST_EXTENSION
|
|
74
|
+
: dumpPath + MANIFEST_EXTENSION;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Host + database name from a connection URL — never the credentials. The
|
|
78
|
+
* name is normalized like the production guard's (`normalizeDatabaseName`:
|
|
79
|
+
* empty path → `postgres`, trailing `/` dropped) so a prompt that shows this
|
|
80
|
+
* name accepts exactly what the guard compared.
|
|
81
|
+
*/
|
|
82
|
+
export function describeDatabase(url) {
|
|
83
|
+
const parsed = new URL(url);
|
|
84
|
+
return { host: parsed.hostname, name: normalizeDatabaseName(parsed.pathname) };
|
|
85
|
+
}
|
|
86
|
+
/** Streaming SHA-256 of a file as lowercase hex. */
|
|
87
|
+
export async function sha256File(filePath) {
|
|
88
|
+
const hash = createHash('sha256');
|
|
89
|
+
for await (const chunk of createReadStream(filePath)) {
|
|
90
|
+
hash.update(chunk);
|
|
91
|
+
}
|
|
92
|
+
return hash.digest('hex');
|
|
93
|
+
}
|
|
94
|
+
export function buildManifest(input) {
|
|
95
|
+
return {
|
|
96
|
+
version: MANIFEST_VERSION,
|
|
97
|
+
createdAt: input.createdAt.toISOString(),
|
|
98
|
+
stamp: stampFor(input.createdAt),
|
|
99
|
+
database: describeDatabase(input.databaseUrl),
|
|
100
|
+
pgDumpVersion: input.pgDumpVersion,
|
|
101
|
+
sizeBytes: input.sizeBytes,
|
|
102
|
+
sha256: input.sha256,
|
|
103
|
+
rowCounts: 'estimate',
|
|
104
|
+
tables: input.tables.map((t) => ({ schema: t.schema, name: t.name, rows: t.rows })),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function isRecord(value) {
|
|
108
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
109
|
+
}
|
|
110
|
+
/** Validate untrusted JSON (downloaded manifest) into a `BackupManifest`. */
|
|
111
|
+
export function parseManifest(value) {
|
|
112
|
+
if (!isRecord(value))
|
|
113
|
+
throw new Error('Backup manifest is not a JSON object.');
|
|
114
|
+
if (value.version !== MANIFEST_VERSION) {
|
|
115
|
+
throw new Error(`Unsupported backup manifest version ${String(value.version)} (expected ${MANIFEST_VERSION}).`);
|
|
116
|
+
}
|
|
117
|
+
const { createdAt, stamp, database, pgDumpVersion, sizeBytes, sha256, tables } = value;
|
|
118
|
+
if (typeof createdAt !== 'string' || Number.isNaN(Date.parse(createdAt))) {
|
|
119
|
+
throw new Error('Backup manifest: createdAt must be an ISO-8601 string.');
|
|
120
|
+
}
|
|
121
|
+
if (typeof stamp !== 'string' || !STAMP_EXACT_RE.test(stamp)) {
|
|
122
|
+
throw new Error('Backup manifest: stamp must be YYYY-MM-DDTHHmmssZ.');
|
|
123
|
+
}
|
|
124
|
+
if (!isRecord(database) ||
|
|
125
|
+
typeof database.host !== 'string' ||
|
|
126
|
+
typeof database.name !== 'string') {
|
|
127
|
+
throw new Error('Backup manifest: database must have string host and name.');
|
|
128
|
+
}
|
|
129
|
+
if (typeof pgDumpVersion !== 'string') {
|
|
130
|
+
throw new Error('Backup manifest: pgDumpVersion must be a string.');
|
|
131
|
+
}
|
|
132
|
+
if (typeof sizeBytes !== 'number' || !Number.isFinite(sizeBytes) || sizeBytes < 0) {
|
|
133
|
+
throw new Error('Backup manifest: sizeBytes must be a non-negative number.');
|
|
134
|
+
}
|
|
135
|
+
if (typeof sha256 !== 'string' || !/^[0-9a-f]{64}$/.test(sha256)) {
|
|
136
|
+
throw new Error('Backup manifest: sha256 must be 64 lowercase hex characters.');
|
|
137
|
+
}
|
|
138
|
+
if (!Array.isArray(tables))
|
|
139
|
+
throw new Error('Backup manifest: tables must be an array.');
|
|
140
|
+
const parsedTables = tables.map((row, i) => {
|
|
141
|
+
if (!isRecord(row) ||
|
|
142
|
+
typeof row.schema !== 'string' ||
|
|
143
|
+
typeof row.name !== 'string' ||
|
|
144
|
+
typeof row.rows !== 'number') {
|
|
145
|
+
throw new Error(`Backup manifest: tables[${i}] must have schema, name and rows.`);
|
|
146
|
+
}
|
|
147
|
+
return { schema: row.schema, name: row.name, rows: row.rows };
|
|
148
|
+
});
|
|
149
|
+
return {
|
|
150
|
+
version: MANIFEST_VERSION,
|
|
151
|
+
createdAt,
|
|
152
|
+
stamp,
|
|
153
|
+
database: { host: database.host, name: database.name },
|
|
154
|
+
pgDumpVersion,
|
|
155
|
+
sizeBytes,
|
|
156
|
+
sha256,
|
|
157
|
+
rowCounts: 'estimate',
|
|
158
|
+
tables: parsedTables,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/backup/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAA;AACjC,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAA;AACzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAA;AAyBlD,MAAM,QAAQ,GAAG,4BAA4B,CAAA;AAC7C,MAAM,cAAc,GAAG,4BAA4B,CAAA;AAEnD,SAAS,GAAG,CAAC,CAAS,EAAE,KAAK,GAAG,CAAC;IAC/B,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AACvC,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,QAAQ,CAAC,IAAU;IACjC,OAAO,CACL,GAAG,IAAI,CAAC,cAAc,EAAE,IAAI,G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E,UAAU;QACrB,MAAM,EAAE,YAAY;KACrB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Readable } from 'node:stream';
|
|
2
|
+
import type { BackupTableRows } from './manifest.js';
|
|
3
|
+
export interface SpawnOptions {
|
|
4
|
+
env?: NodeJS.ProcessEnv;
|
|
5
|
+
}
|
|
6
|
+
/** The slice of `ChildProcess` these helpers rely on. */
|
|
7
|
+
export interface SpawnedProcess {
|
|
8
|
+
stdout: Readable | null;
|
|
9
|
+
stderr: Readable | null;
|
|
10
|
+
on(event: 'error', listener: (err: Error) => void): unknown;
|
|
11
|
+
on(event: 'close', listener: (code: number | null) => void): unknown;
|
|
12
|
+
}
|
|
13
|
+
export type SpawnImpl = (command: string, args: readonly string[], options: SpawnOptions) => SpawnedProcess;
|
|
14
|
+
/** Real `child_process.spawn` adapted to `SpawnImpl` (stdin closed, stdout/stderr piped). */
|
|
15
|
+
export declare const nodeSpawn: SpawnImpl;
|
|
16
|
+
export type PgToolName = 'pg_dump' | 'pg_restore' | 'psql';
|
|
17
|
+
export declare class PgToolError extends Error {
|
|
18
|
+
readonly tool: PgToolName;
|
|
19
|
+
readonly exitCode: number | null;
|
|
20
|
+
constructor(message: string, tool: PgToolName, exitCode: number | null);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Split the password out of a connection URL (decoded, ready for PGPASSWORD).
|
|
24
|
+
*
|
|
25
|
+
* WHATWG `URL.password` is still percent-encoded (`p%40ss`, not `p@ss`), so
|
|
26
|
+
* exactly one `decodeURIComponent` is right. A literal `%` that is not a
|
|
27
|
+
* valid escape (`100%legit`) throws `URIError`; libpq would have used the
|
|
28
|
+
* raw bytes, so the raw value is passed through unchanged.
|
|
29
|
+
*/
|
|
30
|
+
export declare function splitCredentials(url: string): {
|
|
31
|
+
url: string;
|
|
32
|
+
password?: string;
|
|
33
|
+
};
|
|
34
|
+
/** Connection URL safe to print: password replaced by `***`. */
|
|
35
|
+
export declare function redactUrl(url: string): string;
|
|
36
|
+
export type PgToolCheck = {
|
|
37
|
+
ok: true;
|
|
38
|
+
version: string;
|
|
39
|
+
major: number;
|
|
40
|
+
} | {
|
|
41
|
+
ok: false;
|
|
42
|
+
reason: 'missing' | 'too-old' | 'unparseable';
|
|
43
|
+
detail: string;
|
|
44
|
+
};
|
|
45
|
+
/** Probe `<name> --version` and require `major >= minMajor` (`0` = any version). */
|
|
46
|
+
export declare function checkPgTool(name: PgToolName, minMajor?: number, spawnImpl?: SpawnImpl): Promise<PgToolCheck>;
|
|
47
|
+
/** `pg_dump --format=custom --no-owner --no-privileges --file=<out> --dbname=<url>` */
|
|
48
|
+
export declare function runPgDump(databaseUrl: string, outPath: string, spawnImpl?: SpawnImpl, baseEnv?: NodeJS.ProcessEnv): Promise<{
|
|
49
|
+
stderr: string;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* `pg_restore --clean --if-exists --no-owner --no-privileges --no-comments --single-transaction --exit-on-error --dbname=<url> <in>`
|
|
53
|
+
*
|
|
54
|
+
* `--clean` only drops objects that are present in the dump; anything else
|
|
55
|
+
* in the target is left alone. `--single-transaction --exit-on-error` makes
|
|
56
|
+
* the restore atomic: the first error rolls the whole thing back and the
|
|
57
|
+
* target is exactly as it was (DR-sized dumps fit one transaction fine).
|
|
58
|
+
* `--no-comments` drops `COMMENT ON EXTENSION …` statements: pg_dump emits
|
|
59
|
+
* them for `plpgsql` / `pg_trgm`, they need extension ownership that a managed
|
|
60
|
+
* Postgres app role does not have, and under `--exit-on-error` that single
|
|
61
|
+
* harmless failure would otherwise abort the whole restore. The schema
|
|
62
|
+
* carries no comments of its own.
|
|
63
|
+
*/
|
|
64
|
+
export declare function runPgRestore(databaseUrl: string, inPath: string, spawnImpl?: SpawnImpl, baseEnv?: NodeJS.ProcessEnv): Promise<{
|
|
65
|
+
stderr: string;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Planner row estimates for every user table (`pg_class.reltuples`; no table
|
|
69
|
+
* scans). Never-analyzed tables report -1 in PostgreSQL 14+; clamped to 0.
|
|
70
|
+
*/
|
|
71
|
+
export declare function estimateTableRows(databaseUrl: string, spawnImpl?: SpawnImpl, baseEnv?: NodeJS.ProcessEnv): Promise<BackupTableRows[]>;
|
|
72
|
+
/** Exact `count(*)` for each table, in one round-trip (post-restore report). */
|
|
73
|
+
export declare function countTableRows(databaseUrl: string, tables: ReadonlyArray<Pick<BackupTableRows, 'schema' | 'name'>>, spawnImpl?: SpawnImpl, baseEnv?: NodeJS.ProcessEnv): Promise<BackupTableRows[]>;
|
|
74
|
+
//# sourceMappingURL=pg-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pg-tools.d.ts","sourceRoot":"","sources":["../../src/backup/pg-tools.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;CACxB;AAED,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAA;IACvB,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAA;IACvB,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAA;IAC3D,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,OAAO,CAAA;CACrE;AAED,MAAM,MAAM,SAAS,GAAG,CACtB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE,YAAY,KAClB,cAAc,CAAA;AAEnB,6FAA6F;AAC7F,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