@nocobase/plugin-backups 2.1.0-beta.46 → 2.1.0-beta.47

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.
@@ -8,15 +8,15 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-beta.46",
11
+ "@nocobase/client": "2.1.0-beta.47",
12
12
  "react": "18.2.0",
13
- "@nocobase/cache": "2.1.0-beta.46",
14
- "@nocobase/lock-manager": "2.1.0-beta.46",
15
- "@nocobase/server": "2.1.0-beta.46",
13
+ "@nocobase/cache": "2.1.0-beta.47",
14
+ "@nocobase/lock-manager": "2.1.0-beta.47",
15
+ "@nocobase/server": "2.1.0-beta.47",
16
16
  "lodash": "4.18.1",
17
- "@nocobase/database": "2.1.0-beta.46",
17
+ "@nocobase/database": "2.1.0-beta.47",
18
18
  "sequelize": "6.35.2",
19
- "@nocobase/test": "2.1.0-beta.46",
19
+ "@nocobase/test": "2.1.0-beta.47",
20
20
  "@formily/antd-v5": "1.2.3",
21
21
  "@formily/react": "2.3.7",
22
22
  "@formily/reactive": "2.3.7",
@@ -24,8 +24,8 @@ module.exports = {
24
24
  "antd": "5.24.2",
25
25
  "@ant-design/icons": "5.6.1",
26
26
  "ahooks": "3.7.8",
27
- "@nocobase/plugin-file-manager": "2.1.0-beta.46",
28
- "@nocobase/resourcer": "2.1.0-beta.46",
27
+ "@nocobase/plugin-file-manager": "2.1.0-beta.47",
28
+ "@nocobase/resourcer": "2.1.0-beta.47",
29
29
  "dayjs": "1.11.13",
30
- "@nocobase/utils": "2.1.0-beta.46"
30
+ "@nocobase/utils": "2.1.0-beta.47"
31
31
  };
@@ -1 +1 @@
1
- {"name":"archiver","version":"5.3.2","description":"a streaming interface for archive generation","homepage":"https://github.com/archiverjs/node-archiver","author":{"name":"Chris Talkington","url":"http://christalkington.com/"},"repository":{"type":"git","url":"https://github.com/archiverjs/node-archiver.git"},"bugs":{"url":"https://github.com/archiverjs/node-archiver/issues"},"license":"MIT","main":"index.js","files":["index.js","lib"],"engines":{"node":">= 10"},"scripts":{"test":"mocha --reporter dot","bench":"node benchmark/simple/pack-zip.js"},"dependencies":{"archiver-utils":"^2.1.0","async":"^3.2.4","buffer-crc32":"^0.2.1","readable-stream":"^3.6.0","readdir-glob":"^1.1.2","tar-stream":"^2.2.0","zip-stream":"^4.1.0"},"devDependencies":{"archiver-jsdoc-theme":"^1.1.3","chai":"^4.3.7","jsdoc":"^3.6.4","mkdirp":"^2.1.5","mocha":"^9.0.2","rimraf":"^4.3.1","stream-bench":"^0.1.2","tar":"^6.1.13","yauzl":"^2.9.0"},"keywords":["archive","archiver","stream","zip","tar"],"publishConfig":{"registry":"https://registry.npmjs.org/"},"_lastModified":"2026-06-08T07:14:39.210Z"}
1
+ {"name":"archiver","version":"5.3.2","description":"a streaming interface for archive generation","homepage":"https://github.com/archiverjs/node-archiver","author":{"name":"Chris Talkington","url":"http://christalkington.com/"},"repository":{"type":"git","url":"https://github.com/archiverjs/node-archiver.git"},"bugs":{"url":"https://github.com/archiverjs/node-archiver/issues"},"license":"MIT","main":"index.js","files":["index.js","lib"],"engines":{"node":">= 10"},"scripts":{"test":"mocha --reporter dot","bench":"node benchmark/simple/pack-zip.js"},"dependencies":{"archiver-utils":"^2.1.0","async":"^3.2.4","buffer-crc32":"^0.2.1","readable-stream":"^3.6.0","readdir-glob":"^1.1.2","tar-stream":"^2.2.0","zip-stream":"^4.1.0"},"devDependencies":{"archiver-jsdoc-theme":"^1.1.3","chai":"^4.3.7","jsdoc":"^3.6.4","mkdirp":"^2.1.5","mocha":"^9.0.2","rimraf":"^4.3.1","stream-bench":"^0.1.2","tar":"^6.1.13","yauzl":"^2.9.0"},"keywords":["archive","archiver","stream","zip","tar"],"publishConfig":{"registry":"https://registry.npmjs.org/"},"_lastModified":"2026-06-09T23:05:44.491Z"}
@@ -1 +1 @@
1
- {"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2026-06-08T07:14:37.805Z"}
1
+ {"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2026-06-09T23:05:42.958Z"}
@@ -1 +1 @@
1
- {"name":"fs-extra","version":"9.1.0","description":"fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.","engines":{"node":">=10"},"homepage":"https://github.com/jprichardson/node-fs-extra","repository":{"type":"git","url":"https://github.com/jprichardson/node-fs-extra"},"keywords":["fs","file","file system","copy","directory","extra","mkdirp","mkdir","mkdirs","recursive","json","read","write","extra","delete","remove","touch","create","text","output","move","promise"],"author":"JP Richardson <jprichardson@gmail.com>","license":"MIT","dependencies":{"at-least-node":"^1.0.0","graceful-fs":"^4.2.0","jsonfile":"^6.0.1","universalify":"^2.0.0"},"devDependencies":{"coveralls":"^3.0.0","klaw":"^2.1.1","klaw-sync":"^3.0.2","minimist":"^1.1.1","mocha":"^5.0.5","nyc":"^15.0.0","proxyquire":"^2.0.1","read-dir-files":"^0.1.1","standard":"^14.1.0"},"main":"./lib/index.js","files":["lib/","!lib/**/__tests__/"],"scripts":{"full-ci":"npm run lint && npm run coverage","coverage":"nyc -r lcovonly npm run unit","coveralls":"coveralls < coverage/lcov.info","lint":"standard","test-find":"find ./lib/**/__tests__ -name *.test.js | xargs mocha","test":"npm run lint && npm run unit","unit":"node test.js"},"_lastModified":"2026-06-08T07:14:38.133Z"}
1
+ {"name":"fs-extra","version":"9.1.0","description":"fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.","engines":{"node":">=10"},"homepage":"https://github.com/jprichardson/node-fs-extra","repository":{"type":"git","url":"https://github.com/jprichardson/node-fs-extra"},"keywords":["fs","file","file system","copy","directory","extra","mkdirp","mkdir","mkdirs","recursive","json","read","write","extra","delete","remove","touch","create","text","output","move","promise"],"author":"JP Richardson <jprichardson@gmail.com>","license":"MIT","dependencies":{"at-least-node":"^1.0.0","graceful-fs":"^4.2.0","jsonfile":"^6.0.1","universalify":"^2.0.0"},"devDependencies":{"coveralls":"^3.0.0","klaw":"^2.1.1","klaw-sync":"^3.0.2","minimist":"^1.1.1","mocha":"^5.0.5","nyc":"^15.0.0","proxyquire":"^2.0.1","read-dir-files":"^0.1.1","standard":"^14.1.0"},"main":"./lib/index.js","files":["lib/","!lib/**/__tests__/"],"scripts":{"full-ci":"npm run lint && npm run coverage","coverage":"nyc -r lcovonly npm run unit","coveralls":"coveralls < coverage/lcov.info","lint":"standard","test-find":"find ./lib/**/__tests__ -name *.test.js | xargs mocha","test":"npm run lint && npm run unit","unit":"node test.js"},"_lastModified":"2026-06-09T23:05:43.311Z"}
@@ -1 +1 @@
1
- {"name":"semver","version":"7.6.0","description":"The semantic version parser used by npm.","main":"index.js","scripts":{"test":"tap","snap":"tap","lint":"eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"","postlint":"template-oss-check","lintfix":"npm run lint -- --fix","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force"},"devDependencies":{"@npmcli/eslint-config":"^4.0.0","@npmcli/template-oss":"4.21.3","tap":"^16.0.0"},"license":"ISC","repository":{"type":"git","url":"https://github.com/npm/node-semver.git"},"bin":{"semver":"bin/semver.js"},"files":["bin/","lib/","classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"tap":{"timeout":30,"coverage-map":"map.js","nyc-arg":["--exclude","tap-snapshots/**"]},"engines":{"node":">=10"},"dependencies":{"lru-cache":"^6.0.0"},"author":"GitHub Inc.","templateOSS":{"//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten.","version":"4.21.3","engines":">=10","distPaths":["classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"allowPaths":["/classes/","/functions/","/internal/","/ranges/","/index.js","/preload.js","/range.bnf"],"publish":"true"},"_lastModified":"2026-06-08T07:14:39.486Z"}
1
+ {"name":"semver","version":"7.6.0","description":"The semantic version parser used by npm.","main":"index.js","scripts":{"test":"tap","snap":"tap","lint":"eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"","postlint":"template-oss-check","lintfix":"npm run lint -- --fix","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force"},"devDependencies":{"@npmcli/eslint-config":"^4.0.0","@npmcli/template-oss":"4.21.3","tap":"^16.0.0"},"license":"ISC","repository":{"type":"git","url":"https://github.com/npm/node-semver.git"},"bin":{"semver":"bin/semver.js"},"files":["bin/","lib/","classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"tap":{"timeout":30,"coverage-map":"map.js","nyc-arg":["--exclude","tap-snapshots/**"]},"engines":{"node":">=10"},"dependencies":{"lru-cache":"^6.0.0"},"author":"GitHub Inc.","templateOSS":{"//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten.","version":"4.21.3","engines":">=10","distPaths":["classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"allowPaths":["/classes/","/functions/","/internal/","/ranges/","/index.js","/preload.js","/range.bnf"],"publish":"true"},"_lastModified":"2026-06-09T23:05:45.057Z"}
@@ -1 +1 @@
1
- {"name":"yauzl","version":"3.3.0","description":"yet another unzip library for node","engines":{"node":">=12"},"main":"index.js","scripts":{"test":"node test/test.js"},"repository":{"type":"git","url":"git+https://github.com/thejoshwolfe/yauzl.git"},"keywords":["unzip","zip","stream","archive","file"],"author":"Josh Wolfe <thejoshwolfe@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/thejoshwolfe/yauzl/issues"},"homepage":"https://github.com/thejoshwolfe/yauzl","dependencies":{"buffer-crc32":"~0.2.3","pend":"~1.2.0"},"devDependencies":{"bl":"^6.0.11"},"files":["fd-slicer.js","index.js"],"_lastModified":"2026-06-08T07:14:37.971Z"}
1
+ {"name":"yauzl","version":"3.3.0","description":"yet another unzip library for node","engines":{"node":">=12"},"main":"index.js","scripts":{"test":"node test/test.js"},"repository":{"type":"git","url":"git+https://github.com/thejoshwolfe/yauzl.git"},"keywords":["unzip","zip","stream","archive","file"],"author":"Josh Wolfe <thejoshwolfe@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/thejoshwolfe/yauzl/issues"},"homepage":"https://github.com/thejoshwolfe/yauzl","dependencies":{"buffer-crc32":"~0.2.3","pend":"~1.2.0"},"devDependencies":{"bl":"^6.0.11"},"files":["fd-slicer.js","index.js"],"_lastModified":"2026-06-09T23:05:43.140Z"}
@@ -1,8 +1,27 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
1
9
  import { DatabaseOptions } from '@nocobase/database';
10
+ export type DBBackupOptions = {
11
+ dir: string;
12
+ skipFdw?: boolean;
13
+ includeTables?: string[];
14
+ excludeTables?: string[];
15
+ };
16
+ export type DBRestoreOptions = {
17
+ filePath: string;
18
+ schema?: string;
19
+ skipDropAllTables?: boolean;
20
+ };
2
21
  export interface DBAdapter {
3
22
  dbOpts: DatabaseOptions;
4
- backup(dir: string, skipFdw?: boolean): Promise<void>;
5
- restore(filePath: string, schema?: string): Promise<void>;
23
+ backup(options: DBBackupOptions): Promise<void>;
24
+ restore(options: DBRestoreOptions): Promise<void>;
6
25
  check(op: 'backup' | 'restore'): Promise<void>;
7
26
  clientVersion(op: 'backup' | 'restore'): Promise<string | void>;
8
27
  }
@@ -65,6 +65,16 @@ const formatPathInEnv = (path2) => {
65
65
  return path2;
66
66
  };
67
67
  const escapeStringLiteral = (value) => String(value).replace(/'/g, "''");
68
+ const quotePgIdentifier = (value) => `"${String(value).replace(/"/g, '""')}"`;
69
+ const quoteShellArg = (value) => `'${String(value).replace(/'/g, "'\\''")}'`;
70
+ const quotePgTablePattern = (table) => quoteShellArg(String(table).split(".").map(quotePgIdentifier).join("."));
71
+ const qualifyPgTablePattern = (table, schema) => {
72
+ const tablePattern = String(table);
73
+ if (!schema || tablePattern.includes(".")) {
74
+ return tablePattern;
75
+ }
76
+ return `${schema}.${tablePattern}`;
77
+ };
68
78
  class BaseDBAdapter {
69
79
  constructor(dbOpts) {
70
80
  this.dbOpts = dbOpts;
@@ -105,7 +115,7 @@ class MySQLAdapter extends BaseDBAdapter {
105
115
  return void 0;
106
116
  }
107
117
  }
108
- async backup(dir, skipFdw = false) {
118
+ async backup({ dir, skipFdw = false, includeTables, excludeTables }) {
109
119
  const { username, host, port, database, password } = this.dbOpts;
110
120
  const filePath = `${dir}/data`;
111
121
  const versionStr = await this.clientVersion("backup");
@@ -115,6 +125,8 @@ class MySQLAdapter extends BaseDBAdapter {
115
125
  if (!skipFdw) {
116
126
  createServerSQL = await this.#getFederatedServerSQL(username, host, port, database, password);
117
127
  }
128
+ const includeOption = Array.isArray(includeTables) && includeTables.length ? includeTables.map((table) => table) : [];
129
+ const excludeOption = Array.isArray(excludeTables) && excludeTables.length ? excludeTables.map((table) => `--ignore-table=${database}.${table}`) : [];
118
130
  const mysqldumpArgs = [
119
131
  "-u",
120
132
  username,
@@ -131,6 +143,12 @@ class MySQLAdapter extends BaseDBAdapter {
131
143
  ...version && version > 7 ? ["--column-statistics=0"] : [],
132
144
  database
133
145
  ];
146
+ if (excludeOption.length) {
147
+ mysqldumpArgs.push(...excludeOption);
148
+ }
149
+ if (includeOption.length) {
150
+ mysqldumpArgs.push(...includeOption);
151
+ }
134
152
  return new Promise((resolve, reject) => {
135
153
  const mysqldumpProcess = (0, import_child_process.spawn)(this.#backupCmd, mysqldumpArgs, {
136
154
  env: { ...process.env, MYSQL_PWD: password },
@@ -214,9 +232,10 @@ class MySQLAdapter extends BaseDBAdapter {
214
232
  return "";
215
233
  }
216
234
  }
217
- async restore(filePath) {
235
+ async restore({ filePath, skipDropAllTables = false }) {
218
236
  const { username, host, port, database, password } = this.dbOpts;
219
- const dropDataCommand = `mysql -u ${username} -h ${host} ${port ? `-P ${port}` : ""} --protocol=tcp -D ${database} -e "
237
+ if (!skipDropAllTables) {
238
+ const dropDataCommand = `mysql -u ${username} -h ${host} ${port ? `-P ${port}` : ""} --protocol=tcp -D ${database} -e "
220
239
  DELIMITER $$
221
240
  DROP PROCEDURE IF EXISTS drop_all_tables_and_triggers$$
222
241
  CREATE PROCEDURE drop_all_tables_and_triggers()
@@ -296,7 +315,8 @@ class MySQLAdapter extends BaseDBAdapter {
296
315
  DROP PROCEDURE drop_all_tables_and_triggers$$
297
316
  DELIMITER ;
298
317
  "`;
299
- await run(dropDataCommand, { MYSQL_PWD: password });
318
+ await run(dropDataCommand, { MYSQL_PWD: password });
319
+ }
300
320
  const command = `${this.#restoreCmd} -u ${username} -h ${host} ${port ? `-P ${port}` : ""} --protocol=tcp ${database} < ${filePath}`;
301
321
  await run(command, { MYSQL_PWD: password });
302
322
  }
@@ -326,14 +346,16 @@ class PostgresAdapter extends BaseDBAdapter {
326
346
  return void 0;
327
347
  }
328
348
  }
329
- async backup(dir) {
349
+ async backup({ dir, includeTables, excludeTables }) {
330
350
  const { username, host, port, database, password, schema: backupSchema } = this.dbOpts;
331
351
  const filePath = `${dir}/data`;
332
352
  const schemaOption = backupSchema ? `--schema=${backupSchema}` : "";
333
- const command = `${this.#backupCmd} -U ${username} -h ${host} ${port ? `-p ${port}` : ""} -F c -b --quote-all-identifiers ${schemaOption} -f ${filePath} ${database}`;
353
+ const includeOption = Array.isArray(includeTables) && includeTables.length ? includeTables.map((table) => `-t ${quotePgTablePattern(qualifyPgTablePattern(table, backupSchema))}`).join(" ") : "";
354
+ const excludeOption = Array.isArray(excludeTables) && excludeTables.length ? excludeTables.map((table) => `-T ${quotePgTablePattern(qualifyPgTablePattern(table, backupSchema))}`).join(" ") : "";
355
+ const command = `${this.#backupCmd} ${includeOption} ${excludeOption} -U ${username} -h ${host} ${port ? `-p ${port}` : ""} -F c -b --quote-all-identifiers ${schemaOption} -f ${filePath} ${database}`;
334
356
  await run(command, { PGPASSWORD: password });
335
357
  }
336
- async restore(filePath, schema) {
358
+ async restore({ filePath, schema, skipDropAllTables = false }) {
337
359
  const { username, host, port, database, password } = this.dbOpts;
338
360
  let schemaOption = this.dbOpts.schema;
339
361
  if (schema && !schemaOption) {
@@ -343,7 +365,8 @@ class PostgresAdapter extends BaseDBAdapter {
343
365
  const j = Math.max(1, Math.floor(cpuCores / 2));
344
366
  const schemaNameCondition = schemaOption ? `WHERE schemaname = '${schemaOption}'` : `WHERE schemaname NOT IN ('pg_catalog', 'information_schema')`;
345
367
  const relnamespaceCondition = schemaOption ? `WHERE relnamespace = '${schemaOption}'::regnamespace` : `WHERE tgrelid IN (SELECT oid FROM pg_class WHERE relnamespace NOT IN (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname IN ('pg_catalog', 'information_schema')))`;
346
- const dropDataCommand = `psql -U ${username} -h ${host} ${port ? `-p ${port}` : ""} -d ${database} -c "
368
+ if (!skipDropAllTables) {
369
+ const dropDataCommand = `psql -U ${username} -h ${host} ${port ? `-p ${port}` : ""} -d ${database} -c "
347
370
  DO ${D$$} DECLARE r RECORD;
348
371
  BEGIN
349
372
  FOR r IN (SELECT viewname,schemaname FROM pg_views ${schemaNameCondition}) LOOP
@@ -383,7 +406,8 @@ class PostgresAdapter extends BaseDBAdapter {
383
406
  END LOOP;
384
407
 
385
408
  END ${D$$};"`.replace(/\n/g, " ");
386
- await run(dropDataCommand, { PGPASSWORD: password });
409
+ await run(dropDataCommand, { PGPASSWORD: password });
410
+ }
387
411
  if (schema === schemaOption || !schemaOption) {
388
412
  const pgRestoreCommand = `${this.#restoreCmd} -U ${username} -h ${host} ${port ? `-p ${port}` : ""} -d ${database} --clean --if-exists --no-owner -j ${j} ${filePath}`;
389
413
  await run(pgRestoreCommand, { PGPASSWORD: password });
@@ -451,13 +475,13 @@ class PostgresAdapter extends BaseDBAdapter {
451
475
  }
452
476
  }
453
477
  class SQLiteAdapter extends BaseDBAdapter {
454
- async backup(dir) {
478
+ async backup({ dir }) {
455
479
  const { storage } = this.dbOpts;
456
480
  const filePath = `${dir}/data`;
457
481
  const dbFilePath = import_path.default.resolve(storage);
458
482
  await fsPromises.copyFile(dbFilePath, filePath);
459
483
  }
460
- async restore(filePath) {
484
+ async restore({ filePath }) {
461
485
  const { storage } = this.dbOpts;
462
486
  const dbFilePath = import_path.default.resolve(storage);
463
487
  await fsPromises.copyFile(filePath, dbFilePath, fsPromises.constants.COPYFILE_FICLONE);
@@ -1,2 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
1
9
  declare const _default: import("@nocobase/database").CollectionOptions;
2
10
  export default _default;
@@ -33,6 +33,7 @@ var import_database = require("@nocobase/database");
33
33
  var import_utils = require("../utils");
34
34
  var backup_settings_default = (0, import_database.defineCollection)({
35
35
  name: `${import_utils.SETTINGS}`,
36
+ dataCategory: "business",
36
37
  dumpRules: "required",
37
38
  migrationRules: ["overwrite", "skip"],
38
39
  fields: [
@@ -1 +1,13 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export { BackupManager } from './managers/backup';
10
+ export type { BackupSettings, BackupCreator, BackupTaskResult } from './managers/backup';
11
+ export { RestoreManager, RestoreOptions } from './managers/restore';
12
+ export { BACKUP_EXTENSION } from './utils';
1
13
  export { default } from './plugin';
@@ -36,7 +36,21 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var server_exports = {};
38
38
  __export(server_exports, {
39
+ BACKUP_EXTENSION: () => import_utils.BACKUP_EXTENSION,
40
+ BackupManager: () => import_backup.BackupManager,
41
+ RestoreManager: () => import_restore.RestoreManager,
42
+ RestoreOptions: () => import_restore.RestoreOptions,
39
43
  default: () => import_plugin.default
40
44
  });
41
45
  module.exports = __toCommonJS(server_exports);
46
+ var import_backup = require("./managers/backup");
47
+ var import_restore = require("./managers/restore");
48
+ var import_utils = require("./utils");
42
49
  var import_plugin = __toESM(require("./plugin"));
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ BACKUP_EXTENSION,
53
+ BackupManager,
54
+ RestoreManager,
55
+ RestoreOptions
56
+ });
@@ -17,12 +17,22 @@ export interface BackupSettings {
17
17
  keep?: number;
18
18
  scheduled: boolean;
19
19
  cron: string;
20
+ includeTables?: string[];
21
+ excludeTables?: string[];
22
+ description?: string;
23
+ createdBy?: BackupCreator;
20
24
  }
21
25
  export interface BackupFile {
22
26
  name: string;
23
27
  fileSize?: string;
24
28
  createdAt?: Date;
29
+ description?: string;
25
30
  inProgress: boolean;
31
+ createdBy?: BackupCreator;
32
+ }
33
+ export interface BackupCreator {
34
+ id: string;
35
+ username: string;
26
36
  }
27
37
  export interface BackupTaskResult {
28
38
  message?: string;
@@ -33,8 +43,13 @@ export declare class BackupManager {
33
43
  app: Application;
34
44
  ctx: ResourcerContext | null;
35
45
  constructor(app: Application, ctx: ResourcerContext | null, settings: BackupSettings);
46
+ protected set backupPrefix(backupPrefix: string);
47
+ protected set backupDir(backupDir: string);
48
+ protected set tempDir(tempDir: string);
49
+ protected set uploadDir(uploadDir: string);
50
+ protected set backupTasksCacheName(backupTasksCacheName: string);
36
51
  createBackupName(): Promise<string>;
37
- backup(fileBaseName: string, opts?: BackupSettings): Promise<string>;
52
+ backup(fileBaseName: string, opts?: Partial<BackupSettings>): Promise<string>;
38
53
  destroy(fileName: string): Promise<void>;
39
54
  list(): Promise<BackupFile[]>;
40
55
  createReadStream(fileName: string): Promise<Readable>;
@@ -50,12 +50,15 @@ var import_utils = require("@nocobase/utils");
50
50
  var import_util = require("util");
51
51
  var import_database = require("../adapters/database");
52
52
  var import_utils2 = require("../utils");
53
+ const BACKUP_METADATA_VERSION = 1;
53
54
  class BackupManager {
54
55
  app;
55
56
  ctx;
56
57
  // when triggered by cron job, ctx is null
57
58
  #settings;
58
59
  #dbAdapter;
60
+ #backupTasksCacheName;
61
+ #backupPrefix;
59
62
  #backupDir;
60
63
  #tempDir;
61
64
  #uploadDir;
@@ -65,11 +68,28 @@ class BackupManager {
65
68
  this.ctx = ctx;
66
69
  this.#settings = settings;
67
70
  this.#dbAdapter = (0, import_database.getDBAdapter)(app.db.options);
71
+ this.#backupTasksCacheName = import_utils2.BACKUP_TASKS_CACHE_NAME;
72
+ this.#backupPrefix = "backup_";
68
73
  this.#backupDir = (0, import_utils.storagePathJoin)("backups", app.name);
69
74
  this.#tempDir = (0, import_utils.storagePathJoin)("tmp", "backups", app.name);
70
75
  this.#uploadDir = (0, import_utils.storagePathJoin)("uploads");
71
76
  this.#aesKeyPath = (0, import_utils.storagePathJoin)("apps", app.name, "aes_key.dat");
72
77
  }
78
+ set backupPrefix(backupPrefix) {
79
+ this.#backupPrefix = backupPrefix;
80
+ }
81
+ set backupDir(backupDir) {
82
+ this.#backupDir = backupDir;
83
+ }
84
+ set tempDir(tempDir) {
85
+ this.#tempDir = tempDir;
86
+ }
87
+ set uploadDir(uploadDir) {
88
+ this.#uploadDir = uploadDir;
89
+ }
90
+ set backupTasksCacheName(backupTasksCacheName) {
91
+ this.#backupTasksCacheName = backupTasksCacheName;
92
+ }
73
93
  async createBackupName() {
74
94
  await this.#dbAdapter.check("backup");
75
95
  await import_promises.default.mkdir(this.#backupDir, { recursive: true });
@@ -77,19 +97,22 @@ class BackupManager {
77
97
  await import_promises.default.mkdir(this.#uploadDir, { recursive: true });
78
98
  return this.#generateFileBaseName();
79
99
  }
80
- async backup(fileBaseName, opts = this.#settings) {
100
+ async backup(fileBaseName, opts) {
81
101
  const contentPath = import_path.default.join(this.#tempDir, fileBaseName);
82
- return this.#runBackupTask(opts, fileBaseName, contentPath);
102
+ return this.#runBackupTask({ ...this.#settings, ...opts ?? {} }, fileBaseName, contentPath);
83
103
  }
84
104
  async destroy(fileName) {
85
105
  const filePath = this.#getValidatedFilePath(fileName);
106
+ const fileBaseName = import_path.default.basename(filePath, `.${import_utils2.BACKUP_EXTENSION}`);
107
+ const metadataFilePath = import_path.default.join(this.#backupDir, `${fileBaseName}${import_utils2.METADATA_EXTENSION}`);
86
108
  await import_promises.default.unlink(filePath);
109
+ await import_promises.default.rm(metadataFilePath, { force: true });
87
110
  }
88
111
  async list() {
89
112
  const inProgressBackups = await this.#listProgressBackups();
90
113
  const completedBackups = await this.#listCompletedBackups(inProgressBackups);
91
114
  const cleanStaleLockFiles = async () => {
92
- const statusCache = this.app.cacheManager.getCache(import_utils2.BACKUP_TASKS_CACHE_NAME);
115
+ const statusCache = this.app.cacheManager.getCache(this.#backupTasksCacheName);
93
116
  for (const backup of inProgressBackups) {
94
117
  if (!await statusCache.get(backup.name)) {
95
118
  await this.#removeLockFile(import_path.default.basename(backup.name, `.${import_utils2.BACKUP_EXTENSION}`));
@@ -116,7 +139,12 @@ class BackupManager {
116
139
  try {
117
140
  await this.#createLockFile(fileBaseName);
118
141
  await this.#createContentPath(contentPath);
119
- await this.#dbAdapter.backup(contentPath, !this.app.pm.has("collection-fdw"));
142
+ await this.#dbAdapter.backup({
143
+ dir: contentPath,
144
+ skipFdw: !this.app.pm.has("collection-fdw"),
145
+ includeTables: opts.includeTables,
146
+ excludeTables: opts.excludeTables
147
+ });
120
148
  await this.#metadataBackup(opts, contentPath);
121
149
  const password = opts.encryptionPassword || void 0;
122
150
  const filePath = await this.#compressFiles(contentPath, fileBaseName, password, opts);
@@ -159,8 +187,11 @@ class BackupManager {
159
187
  };
160
188
  });
161
189
  const metadata = {
190
+ metadataVersion: BACKUP_METADATA_VERSION,
162
191
  enableFilesBackup: opts.enableFilesBackup,
163
192
  version: await this.app.version.get(),
193
+ description: opts.description,
194
+ createdBy: opts.createdBy,
164
195
  database: {
165
196
  dialect,
166
197
  underscored,
@@ -171,7 +202,7 @@ class BackupManager {
171
202
  },
172
203
  plugins
173
204
  };
174
- const metadataFilePath = import_path.default.join(dir, "_metadata.json");
205
+ const metadataFilePath = import_path.default.join(dir, import_utils2.METADATA_EXTENSION);
175
206
  try {
176
207
  await import_promises.default.writeFile(metadataFilePath, JSON.stringify(metadata, null, 2));
177
208
  } catch (error) {
@@ -183,6 +214,8 @@ class BackupManager {
183
214
  zlib: { level: 9 }
184
215
  });
185
216
  const filePath = import_path.default.join(this.#backupDir, `${fileBaseName}.${import_utils2.BACKUP_EXTENSION}`);
217
+ const sourceMetadataFilePath = import_path.default.join(dir, import_utils2.METADATA_EXTENSION);
218
+ const metadataFilePath = import_path.default.join(this.#backupDir, `${fileBaseName}${import_utils2.METADATA_EXTENSION}`);
186
219
  const outputFileStream = fs.createWriteStream(filePath);
187
220
  try {
188
221
  const output = await this.#createEncryptedStream(outputFileStream, password);
@@ -253,6 +286,7 @@ class BackupManager {
253
286
  }
254
287
  await archive.finalize();
255
288
  await onClose;
289
+ await import_promises.default.copyFile(sourceMetadataFilePath, metadataFilePath);
256
290
  } catch (error) {
257
291
  this.app.logger.error(`Error compressing files: ${error.message}`, { module: import_utils2.BACKUPS });
258
292
  throw new Error(this.#t("ERROR_COMPRESSING_FILES", error.message));
@@ -385,7 +419,7 @@ class BackupManager {
385
419
  }
386
420
  }
387
421
  #generateFileBaseName() {
388
- return `backup_${(0, import_dayjs.default)().format(`YYYYMMDD_HHmmss_${Math.floor(1e3 + Math.random() * 9e3)}`)}`;
422
+ return `${this.#backupPrefix}${(0, import_dayjs.default)().format(`YYYYMMDD_HHmmss_${Math.floor(1e3 + Math.random() * 9e3)}`)}`;
389
423
  }
390
424
  async #listCompletedBackups(inProgressFiles = []) {
391
425
  let files;
@@ -400,17 +434,35 @@ class BackupManager {
400
434
  }
401
435
  const inProgressFileNames = inProgressFiles.map((file) => file.name);
402
436
  const backupPromises = files.filter((file) => file.endsWith(`.${import_utils2.BACKUP_EXTENSION}`) && !inProgressFileNames.includes(file)).map(async (file) => {
403
- const stats = await import_promises.default.stat(import_path.default.join(this.#backupDir, file));
437
+ const fileBaseName = import_path.default.basename(file, `.${import_utils2.BACKUP_EXTENSION}`);
438
+ const metadataFilePath = import_path.default.join(this.#backupDir, `${fileBaseName}${import_utils2.METADATA_EXTENSION}`);
439
+ const [stats, metadata] = await Promise.all([
440
+ import_promises.default.stat(import_path.default.join(this.#backupDir, file)),
441
+ this.#readBackupDescription(metadataFilePath)
442
+ ]);
404
443
  return {
405
444
  name: file,
406
445
  fileSize: (0, import_utils2.humanFileSize)(stats.size),
407
446
  createdAt: stats.ctime,
447
+ description: metadata == null ? void 0 : metadata.description,
448
+ createdBy: metadata == null ? void 0 : metadata.createdBy,
408
449
  inProgress: false
409
450
  };
410
451
  });
411
452
  const backups = await Promise.all(backupPromises);
412
453
  return backups.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
413
454
  }
455
+ async #readBackupDescription(metadataFilePath) {
456
+ try {
457
+ const metadata = JSON.parse(await import_promises.default.readFile(metadataFilePath, "utf8"));
458
+ return {
459
+ description: metadata.description,
460
+ createdBy: metadata.createdBy
461
+ };
462
+ } catch (_error) {
463
+ return void 0;
464
+ }
465
+ }
414
466
  async #listProgressBackups() {
415
467
  try {
416
468
  const files = await import_promises.default.readdir(this.#tempDir);
@@ -8,17 +8,21 @@
8
8
  */
9
9
  /// <reference types="multer" />
10
10
  import { ResourcerContext } from '@nocobase/resourcer';
11
- interface RestoreOptions {
11
+ export interface RestoreOptions {
12
12
  forceSchemaRestore?: boolean;
13
+ skipDropAllTables?: boolean;
13
14
  }
14
15
  export declare class RestoreManager {
15
16
  #private;
16
17
  ctx: ResourcerContext;
17
18
  constructor(ctx: ResourcerContext, dbOptions?: any);
19
+ protected set backupDir(backupDir: string);
20
+ protected set tempDir(tempDir: string);
21
+ protected set uploadDir(uploadDir: string);
22
+ protected set restoreTasksCacheName(restoreTasksCacheName: string);
18
23
  restoreFromBackup(backupFileName: string, taskId: string, password?: string, tolerentMode?: boolean, options?: RestoreOptions): Promise<void>;
19
24
  restoreFromUpload(backupFile: Express.Multer.File, taskId: string, password?: string, tolerentMode?: boolean, options?: RestoreOptions): Promise<void>;
20
25
  restoreCLI(filePath: string, password?: string, tolerentMode?: boolean, skipRevertOnError?: boolean, options?: RestoreOptions): Promise<void>;
21
- private getStatusCache;
26
+ protected getStatusCache(): Promise<any>;
22
27
  restore(filePath: string, taskId: string, password?: string, tolerentMode?: boolean, skipRevertOnError?: boolean, options?: RestoreOptions): Promise<void>;
23
28
  }
24
- export {};
@@ -57,6 +57,7 @@ const RESTORE_STEPS = {
57
57
  class RestoreManager {
58
58
  ctx;
59
59
  #dbAdapter;
60
+ #restoreTasksCacheName;
60
61
  #backupDir;
61
62
  #tempDir;
62
63
  #uploadDir;
@@ -64,11 +65,24 @@ class RestoreManager {
64
65
  constructor(ctx, dbOptions) {
65
66
  this.ctx = ctx;
66
67
  this.#dbAdapter = (0, import_database.getDBAdapter)(dbOptions || ctx.app.db.options);
68
+ this.#restoreTasksCacheName = import_utils2.RESTORE_TASKS_CACHE_NAME;
67
69
  this.#backupDir = (0, import_utils.storagePathJoin)("backups", ctx.app.name);
68
70
  this.#tempDir = (0, import_utils.storagePathJoin)("tmp", "backups", ctx.app.name);
69
71
  this.#uploadDir = (0, import_utils.storagePathJoin)("uploads");
70
72
  this.#aesKeyPath = (0, import_utils.storagePathJoin)("apps", ctx.app.name, "aes_key.dat");
71
73
  }
74
+ set backupDir(backupDir) {
75
+ this.#backupDir = backupDir;
76
+ }
77
+ set tempDir(tempDir) {
78
+ this.#tempDir = tempDir;
79
+ }
80
+ set uploadDir(uploadDir) {
81
+ this.#uploadDir = uploadDir;
82
+ }
83
+ set restoreTasksCacheName(restoreTasksCacheName) {
84
+ this.#restoreTasksCacheName = restoreTasksCacheName;
85
+ }
72
86
  async restoreFromBackup(backupFileName, taskId, password, tolerentMode, options) {
73
87
  const backupFilePath = this.#getValidatedBackupFilePath(backupFileName);
74
88
  await this.restore(backupFilePath, taskId, password, tolerentMode, void 0, options);
@@ -90,7 +104,7 @@ class RestoreManager {
90
104
  }
91
105
  const metadata = await this.#parseMetadataFile(import_path.default.join(extractedDir, metadataFile), tolerentMode, options);
92
106
  try {
93
- await this.#restoreDataCLI(extractedDir, dbFile, uploadsExist, metadata);
107
+ await this.#restoreDataCLI(extractedDir, dbFile, uploadsExist, metadata, options);
94
108
  } catch (error) {
95
109
  const dbVersion = await (0, import_utils2.getDBVersion)(this.ctx.app.db);
96
110
  const restoreClientVersion = await this.#dbAdapter.clientVersion("restore");
@@ -119,13 +133,17 @@ class RestoreManager {
119
133
  }
120
134
  return filePath;
121
135
  }
122
- async #restoreDataCLI(extractedDir, dbFile, restoreUploads, metadata) {
136
+ async #restoreDataCLI(extractedDir, dbFile, restoreUploads, metadata, options) {
123
137
  const tmpBackupDir = import_path.default.join(this.#tempDir, "before-restore");
124
138
  try {
125
139
  await import_fs_extra.default.mkdir(tmpBackupDir, { recursive: true });
126
140
  await this.ctx.app.emitAsync("beforeStop");
127
141
  await this.ctx.app.emitAsync("afterStop");
128
- await this.#dbAdapter.restore(import_path.default.join(extractedDir, dbFile), metadata.database.schema);
142
+ await this.#dbAdapter.restore({
143
+ filePath: import_path.default.join(extractedDir, dbFile),
144
+ schema: metadata.database.schema,
145
+ skipDropAllTables: (options == null ? void 0 : options.skipDropAllTables) === true
146
+ });
129
147
  this.ctx.logger.info("Database restored successfully", { module: import_utils2.BACKUPS });
130
148
  await this.#restoreFilesAndCleanup(restoreUploads, extractedDir);
131
149
  } catch (error) {
@@ -137,10 +155,10 @@ class RestoreManager {
137
155
  }
138
156
  async getStatusCache() {
139
157
  try {
140
- return this.ctx.app.cacheManager.getCache(import_utils2.RESTORE_TASKS_CACHE_NAME);
158
+ return this.ctx.app.cacheManager.getCache(this.#restoreTasksCacheName);
141
159
  } catch (e) {
142
160
  return await this.ctx.app.cacheManager.createCache({
143
- name: import_utils2.RESTORE_TASKS_CACHE_NAME,
161
+ name: this.#restoreTasksCacheName,
144
162
  store: "memory",
145
163
  ttl: import_utils2.RESTORE_TASKS_CACHE_TTL,
146
164
  max: 10
@@ -159,7 +177,7 @@ class RestoreManager {
159
177
  throw new Error(this.#t("Not a valid backup file"));
160
178
  }
161
179
  const metadata = await this.#parseMetadataFile(import_path.default.join(extractedDir, metadataFile), tolerentMode, options);
162
- this.#restoreData(extractedDir, dbFile, uploadsExist, taskId, metadata).catch(async (error) => {
180
+ this.#restoreData(extractedDir, dbFile, uploadsExist, taskId, metadata, options).catch(async (error) => {
163
181
  try {
164
182
  const dbVersion = await (0, import_utils2.getDBVersion)(this.ctx.app.db);
165
183
  const restoreClientVersion = await this.#dbAdapter.clientVersion("restore");
@@ -341,17 +359,21 @@ class RestoreManager {
341
359
  throw error;
342
360
  }
343
361
  }
344
- async #restoreData(extractedDir, dbFile, restoreUploads, taskId, metadata) {
362
+ async #restoreData(extractedDir, dbFile, restoreUploads, taskId, metadata, options) {
345
363
  this.#notify(RESTORE_STEPS.BEGIN);
346
364
  this.#notify(RESTORE_STEPS.DATABASE);
347
365
  const statusCache = await this.getStatusCache();
348
366
  const tmpBackupDir = import_path.default.join(this.#tempDir, "before-restore");
349
367
  try {
350
368
  await import_promises.default.mkdir(tmpBackupDir, { recursive: true });
351
- await this.#dbAdapter.backup(tmpBackupDir);
369
+ await this.#dbAdapter.backup({ dir: tmpBackupDir });
352
370
  await this.ctx.app.emitAsync("beforeStop");
353
371
  await this.ctx.app.emitAsync("afterStop");
354
- await this.#dbAdapter.restore(import_path.default.join(extractedDir, dbFile), metadata.database.schema);
372
+ await this.#dbAdapter.restore({
373
+ filePath: import_path.default.join(extractedDir, dbFile),
374
+ schema: metadata.database.schema,
375
+ skipDropAllTables: (options == null ? void 0 : options.skipDropAllTables) === true
376
+ });
355
377
  this.ctx.logger.info("Database restored successfully", { module: import_utils2.BACKUPS });
356
378
  if (restoreUploads) {
357
379
  this.#notify(RESTORE_STEPS.UPLOADS);
@@ -393,7 +415,7 @@ class RestoreManager {
393
415
  const dbFile = import_path.default.join(this.#tempDir, "before-restore", "data");
394
416
  if (await import_fs_extra.default.pathExists(dbFile)) {
395
417
  try {
396
- await this.#dbAdapter.restore(dbFile, this.#dbAdapter.dbOpts.schema);
418
+ await this.#dbAdapter.restore({ filePath: dbFile, schema: this.#dbAdapter.dbOpts.schema });
397
419
  } catch (error) {
398
420
  this.ctx.logger.error("Error reverting the database restore process", { module: import_utils2.BACKUPS });
399
421
  }
@@ -9,6 +9,7 @@
9
9
  /// <reference types="node" />
10
10
  /// <reference types="node" />
11
11
  export declare const BACKUP_EXTENSION = "nbdata";
12
+ export declare const METADATA_EXTENSION = "_metadata.json";
12
13
  export declare const STORAGE_PATH = "storage/uploads";
13
14
  export declare const SETTINGS = "backupSettings";
14
15
  export declare const BACKUPS = "backups";
@@ -42,6 +42,7 @@ __export(utils_exports, {
42
42
  EscapeQuoteTransform: () => EscapeQuoteTransform,
43
43
  Extractor: () => Extractor,
44
44
  FILE_ENCRYPTION_SALT: () => FILE_ENCRYPTION_SALT,
45
+ METADATA_EXTENSION: () => METADATA_EXTENSION,
45
46
  PLUGIN_BACKUPS_NAME: () => PLUGIN_BACKUPS_NAME,
46
47
  RESTORE_TASKS_CACHE_NAME: () => RESTORE_TASKS_CACHE_NAME,
47
48
  RESTORE_TASKS_CACHE_TTL: () => RESTORE_TASKS_CACHE_TTL,
@@ -61,6 +62,7 @@ var import_path = __toESM(require("path"));
61
62
  var import_sequelize = require("sequelize");
62
63
  var import_package = require("../../package.json");
63
64
  const BACKUP_EXTENSION = "nbdata";
65
+ const METADATA_EXTENSION = "_metadata.json";
64
66
  const STORAGE_PATH = "storage/uploads";
65
67
  const SETTINGS = "backupSettings";
66
68
  const BACKUPS = "backups";
@@ -310,6 +312,7 @@ class EscapeQuoteTransform extends import_stream.Transform {
310
312
  EscapeQuoteTransform,
311
313
  Extractor,
312
314
  FILE_ENCRYPTION_SALT,
315
+ METADATA_EXTENSION,
313
316
  PLUGIN_BACKUPS_NAME,
314
317
  RESTORE_TASKS_CACHE_NAME,
315
318
  RESTORE_TASKS_CACHE_TTL,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "备份管理器",
5
5
  "description": "Provides backup and restore functionality, supports scheduled backups, and ensures data security and quick recovery.",
6
6
  "description.zh-CN": "提供备份与还原功能,支持定时备份,确保数据安全与快速恢复。",
7
- "version": "2.1.0-beta.46",
7
+ "version": "2.1.0-beta.47",
8
8
  "license": "Apache-2.0",
9
9
  "main": "dist/server/index.js",
10
10
  "nocobase": {
@@ -47,5 +47,5 @@
47
47
  "keywords": [
48
48
  "System management"
49
49
  ],
50
- "gitHead": "91fd3ab238a5ff58735bbfca04a8cb05d233b0af"
50
+ "gitHead": "bf8fc3790e3494c901b4d22861c5471a0d27c464"
51
51
  }