@datatruck/cli 0.16.1 → 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/Action/BackupAction.d.ts +14 -5
- package/Action/BackupAction.js +34 -11
- package/Action/BackupSessionsAction.d.ts +1 -1
- package/Action/CleanCacheAction.d.ts +1 -1
- package/Action/ConfigAction.d.ts +1 -1
- package/Action/InitAction.d.ts +1 -1
- package/Action/PruneAction.d.ts +2 -2
- package/Action/RestoreAction.d.ts +12 -6
- package/Action/RestoreAction.js +24 -10
- package/Action/RestoreSessionsAction.d.ts +1 -1
- package/Action/SnapshotsAction.d.ts +3 -3
- package/Command/BackupCommand.d.ts +1 -1
- package/Command/BackupSessionsCommand.d.ts +1 -1
- package/Command/CleanCacheCommand.d.ts +1 -1
- package/Command/CommandAbstract.d.ts +2 -2
- package/Command/ConfigCommand.d.ts +2 -2
- package/Command/InitCommand.d.ts +2 -2
- package/Command/PruneCommand.d.ts +1 -1
- package/Command/RestoreCommand.d.ts +1 -1
- package/Command/RestoreSessionsCommand.d.ts +1 -1
- package/Command/SnapshotsCommand.d.ts +2 -2
- package/Command/SnapshotsCommand.js +6 -1
- package/Config/Config.d.ts +1 -1
- package/Config/PackageConfig.d.ts +2 -2
- package/Config/PackageRepositoryConfig.d.ts +1 -1
- package/Config/PrunePolicyConfig.d.ts +1 -1
- package/Config/RepositoryConfig.d.ts +3 -3
- package/Config/TaskConfig.d.ts +1 -1
- package/Decorator/EntityDecorator.d.ts +1 -1
- package/Factory/CommandFactory.d.ts +2 -2
- package/Repository/DatatruckRepository.d.ts +4 -4
- package/Repository/DatatruckRepository.js +1 -1
- package/Repository/GitRepository.d.ts +2 -2
- package/Repository/GitRepository.js +3 -3
- package/Repository/RepositoryAbstract.d.ts +11 -9
- package/Repository/RepositoryAbstract.js +7 -0
- package/Repository/ResticRepository.d.ts +2 -2
- package/Repository/ResticRepository.js +3 -1
- package/SessionDriver/ConsoleSessionDriver.d.ts +3 -3
- package/SessionDriver/SessionDriverAbstract.d.ts +4 -4
- package/SessionManager/SessionManagerAbstract.d.ts +1 -1
- package/Task/GitTask.d.ts +1 -1
- package/Task/GitTask.js +2 -2
- package/Task/MariadbTask.d.ts +1 -1
- package/Task/MariadbTask.js +1 -1
- package/Task/MssqlTask.d.ts +1 -1
- package/Task/MysqlDumpTask.d.ts +1 -1
- package/Task/PostgresqlDumpTask.d.ts +1 -1
- package/Task/ScriptTask.d.ts +5 -5
- package/Task/ScriptTask.js +6 -6
- package/Task/SqlDumpTaskAbstract.d.ts +2 -2
- package/Task/SqlDumpTaskAbstract.js +2 -2
- package/Task/TaskAbstract.d.ts +4 -2
- package/Task/TaskAbstract.js +7 -0
- package/package.json +8 -8
- package/util/DataFormat.d.ts +1 -1
- package/util/ObjectVault.d.ts +1 -1
- package/util/ResticUtil.d.ts +3 -2
- package/util/ResticUtil.js +12 -10
- package/util/cli-util.d.ts +1 -1
- package/util/datatruck/config-util.d.ts +9 -9
- package/util/datatruck/config-util.js +1 -1
- package/util/date-util.d.ts +1 -1
- package/util/fs-util.d.ts +4 -1
- package/util/fs-util.js +21 -3
- package/util/object-util.d.ts +1 -1
- package/util/process-util.d.ts +3 -3
- package/util/progress.d.ts +2 -2
- package/util/string-util.d.ts +1 -1
- package/util/zip-util.d.ts +3 -3
package/Action/BackupAction.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ConfigType } from "../Config/Config";
|
|
2
2
|
import { PackageConfigType } from "../Config/PackageConfig";
|
|
3
3
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
4
|
-
import { TaskConfigType } from "../Config/TaskConfig";
|
|
5
4
|
import { AppError } from "../Error/AppError";
|
|
6
5
|
import { SnapshotType } from "../Repository/RepositoryAbstract";
|
|
7
6
|
import { BackupSessionManager } from "../SessionManager/BackupSessionManager";
|
|
7
|
+
import { TaskAbstract } from "../Task/TaskAbstract";
|
|
8
8
|
import { IfRequireKeys } from "../util/ts-util";
|
|
9
|
-
export
|
|
9
|
+
export type BackupActionOptionsType = {
|
|
10
10
|
repositoryNames?: string[];
|
|
11
11
|
repositoryTypes?: string[];
|
|
12
12
|
packageNames?: string[];
|
|
@@ -23,9 +23,18 @@ export declare class BackupAction<TRequired extends boolean = true> {
|
|
|
23
23
|
protected repoErrors: Record<string, Error[]>;
|
|
24
24
|
constructor(config: ConfigType, options?: IfRequireKeys<TRequired, BackupActionOptionsType>);
|
|
25
25
|
protected init(session: BackupSessionManager): Promise<[SnapshotType, PackageConfigType[]]>;
|
|
26
|
-
protected task(session: BackupSessionManager, pkg: PackageConfigType, task:
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
protected task(session: BackupSessionManager, pkg: PackageConfigType, task: TaskAbstract<any>, snapshot: SnapshotType, targetPath: string | undefined): Promise<{
|
|
27
|
+
error: boolean;
|
|
28
|
+
tmpDirs: string[];
|
|
29
|
+
}>;
|
|
30
|
+
protected backup(session: BackupSessionManager, pkg: PackageConfigType, repo: RepositoryConfigType, snapshot: SnapshotType, targetPath: string | undefined): Promise<{
|
|
31
|
+
error: boolean;
|
|
32
|
+
tmpDirs: string[];
|
|
33
|
+
}>;
|
|
34
|
+
protected copyBackup(session: BackupSessionManager, pkg: PackageConfigType, repo: RepositoryConfigType, mirrorRepo: RepositoryConfigType, snapshot: SnapshotType): Promise<{
|
|
35
|
+
error: boolean;
|
|
36
|
+
tmpDirs: string[];
|
|
37
|
+
}>;
|
|
29
38
|
protected getError(pkg: PackageConfigType): AppError | null;
|
|
30
39
|
protected splitRepositories(repositoryNames: string[]): {
|
|
31
40
|
repoNames: string[];
|
package/Action/BackupAction.js
CHANGED
|
@@ -5,6 +5,7 @@ const AppError_1 = require("../Error/AppError");
|
|
|
5
5
|
const RepositoryFactory_1 = require("../Factory/RepositoryFactory");
|
|
6
6
|
const TaskFactory_1 = require("../Factory/TaskFactory");
|
|
7
7
|
const config_util_1 = require("../util/datatruck/config-util");
|
|
8
|
+
const fs_util_1 = require("../util/fs-util");
|
|
8
9
|
const crypto_1 = require("crypto");
|
|
9
10
|
class BackupAction {
|
|
10
11
|
constructor(config, options = {}) {
|
|
@@ -56,7 +57,7 @@ class BackupAction {
|
|
|
56
57
|
async task(session, pkg, task, snapshot, targetPath) {
|
|
57
58
|
const taskId = session.findTaskId({
|
|
58
59
|
packageName: pkg.name,
|
|
59
|
-
taskName: task.name,
|
|
60
|
+
taskName: pkg.task.name,
|
|
60
61
|
});
|
|
61
62
|
await session.startTask({
|
|
62
63
|
id: taskId,
|
|
@@ -68,8 +69,7 @@ class BackupAction {
|
|
|
68
69
|
}
|
|
69
70
|
else {
|
|
70
71
|
try {
|
|
71
|
-
|
|
72
|
-
await taskInstance.onBackup({
|
|
72
|
+
await task.onBackup({
|
|
73
73
|
package: pkg,
|
|
74
74
|
options: this.options,
|
|
75
75
|
snapshot,
|
|
@@ -92,7 +92,10 @@ class BackupAction {
|
|
|
92
92
|
id: taskId,
|
|
93
93
|
error: error?.stack,
|
|
94
94
|
});
|
|
95
|
-
return
|
|
95
|
+
return {
|
|
96
|
+
error: error ? false : true,
|
|
97
|
+
tmpDirs: task.tmpDirs,
|
|
98
|
+
};
|
|
96
99
|
}
|
|
97
100
|
async backup(session, pkg, repo, snapshot, targetPath) {
|
|
98
101
|
const repositoryId = session.findRepositoryId({
|
|
@@ -103,12 +106,13 @@ class BackupAction {
|
|
|
103
106
|
id: repositoryId,
|
|
104
107
|
});
|
|
105
108
|
let error;
|
|
109
|
+
let repoInstance;
|
|
106
110
|
if (this.taskErrors[pkg.name]?.length) {
|
|
107
111
|
error = new AppError_1.AppError("Task failed");
|
|
108
112
|
}
|
|
109
113
|
else {
|
|
110
114
|
try {
|
|
111
|
-
|
|
115
|
+
repoInstance = (0, RepositoryFactory_1.RepositoryFactory)(repo);
|
|
112
116
|
await repoInstance.onBackup({
|
|
113
117
|
package: pkg,
|
|
114
118
|
targetPath,
|
|
@@ -134,7 +138,10 @@ class BackupAction {
|
|
|
134
138
|
id: repositoryId,
|
|
135
139
|
error: error?.stack,
|
|
136
140
|
});
|
|
137
|
-
return
|
|
141
|
+
return {
|
|
142
|
+
error: error ? false : true,
|
|
143
|
+
tmpDirs: repoInstance?.tmpDirs ?? [],
|
|
144
|
+
};
|
|
138
145
|
}
|
|
139
146
|
async copyBackup(session, pkg, repo, mirrorRepo, snapshot) {
|
|
140
147
|
const repositoryId = session.findRepositoryId({
|
|
@@ -145,12 +152,13 @@ class BackupAction {
|
|
|
145
152
|
id: repositoryId,
|
|
146
153
|
});
|
|
147
154
|
let error;
|
|
155
|
+
let repoInstance;
|
|
148
156
|
if (this.taskErrors[pkg.name]?.length) {
|
|
149
157
|
error = new AppError_1.AppError("Task failed");
|
|
150
158
|
}
|
|
151
159
|
else {
|
|
152
160
|
try {
|
|
153
|
-
|
|
161
|
+
repoInstance = (0, RepositoryFactory_1.RepositoryFactory)(repo);
|
|
154
162
|
await repoInstance.onCopyBackup({
|
|
155
163
|
options: this.options,
|
|
156
164
|
package: pkg,
|
|
@@ -174,7 +182,10 @@ class BackupAction {
|
|
|
174
182
|
id: repositoryId,
|
|
175
183
|
error: error?.stack,
|
|
176
184
|
});
|
|
177
|
-
return
|
|
185
|
+
return {
|
|
186
|
+
error: error ? false : true,
|
|
187
|
+
tmpDirs: repoInstance?.tmpDirs ?? [],
|
|
188
|
+
};
|
|
178
189
|
}
|
|
179
190
|
getError(pkg) {
|
|
180
191
|
const taskErrors = this.taskErrors[pkg.name]?.length;
|
|
@@ -226,6 +237,7 @@ class BackupAction {
|
|
|
226
237
|
id,
|
|
227
238
|
});
|
|
228
239
|
let targetPath;
|
|
240
|
+
let taskTmpDirs = [];
|
|
229
241
|
if (pkg.task) {
|
|
230
242
|
const taskInstance = (0, TaskFactory_1.TaskFactory)(pkg.task);
|
|
231
243
|
const result = await taskInstance.onBeforeBackup({
|
|
@@ -233,17 +245,28 @@ class BackupAction {
|
|
|
233
245
|
package: pkg,
|
|
234
246
|
snapshot,
|
|
235
247
|
});
|
|
236
|
-
await this.task(session, pkg,
|
|
248
|
+
const taskResult = await this.task(session, pkg, taskInstance, snapshot, (targetPath = result?.targetPath));
|
|
249
|
+
taskTmpDirs.push(...taskResult.tmpDirs);
|
|
237
250
|
}
|
|
238
251
|
const { repoNames, mirrors } = this.splitRepositories(pkg.repositoryNames ?? []);
|
|
239
252
|
for (const repoName of repoNames) {
|
|
240
253
|
const repo = (0, config_util_1.findRepositoryOrFail)(this.config, repoName);
|
|
241
|
-
await this.backup(session, pkg, repo, snapshot, targetPath);
|
|
254
|
+
const { tmpDirs } = await this.backup(session, pkg, repo, snapshot, targetPath);
|
|
255
|
+
if (!this.options.verbose)
|
|
256
|
+
await (0, fs_util_1.rmTmpDir)(tmpDirs);
|
|
257
|
+
}
|
|
258
|
+
if (!this.options.verbose) {
|
|
259
|
+
await (0, fs_util_1.rmTmpDir)(taskTmpDirs);
|
|
260
|
+
if (pkg.path && (0, fs_util_1.isTmpDir)(pkg.path)) {
|
|
261
|
+
await (0, fs_util_1.rmTmpDir)(pkg.path);
|
|
262
|
+
}
|
|
242
263
|
}
|
|
243
264
|
for (const mirror of mirrors) {
|
|
244
265
|
const repo = (0, config_util_1.findRepositoryOrFail)(this.config, mirror.sourceName);
|
|
245
266
|
const mirrorRepo = (0, config_util_1.findRepositoryOrFail)(this.config, mirror.name);
|
|
246
|
-
await this.copyBackup(session, pkg, repo, mirrorRepo, snapshot);
|
|
267
|
+
const { tmpDirs } = await this.copyBackup(session, pkg, repo, mirrorRepo, snapshot);
|
|
268
|
+
if (!this.options.verbose)
|
|
269
|
+
await (0, fs_util_1.rmTmpDir)(tmpDirs);
|
|
247
270
|
}
|
|
248
271
|
const error = this.getError(pkg);
|
|
249
272
|
if (error)
|
|
@@ -2,7 +2,7 @@ import type { ConfigType } from "../Config/Config";
|
|
|
2
2
|
import { ReadDataType } from "../SessionDriver/SessionDriverAbstract";
|
|
3
3
|
import { BackupSessionManager } from "../SessionManager/BackupSessionManager";
|
|
4
4
|
import { IfRequireKeys } from "../util/ts-util";
|
|
5
|
-
export
|
|
5
|
+
export type BackupSessionsActionOptionsType = ReadDataType & {
|
|
6
6
|
verbose?: boolean;
|
|
7
7
|
};
|
|
8
8
|
export declare class BackupSessionsAction<TRequired extends boolean = true> {
|
package/Action/ConfigAction.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GlobalOptionsType } from "../Command/CommandAbstract";
|
|
2
2
|
import type { ConfigType } from "../Config/Config";
|
|
3
3
|
import { IfRequireKeys } from "../util/ts-util";
|
|
4
|
-
export
|
|
4
|
+
export type ConfigActionOptionsType = {
|
|
5
5
|
path: string;
|
|
6
6
|
verbose?: boolean;
|
|
7
7
|
};
|
package/Action/InitAction.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConfigType } from "../Config/Config";
|
|
2
2
|
import { IfRequireKeys } from "../util/ts-util";
|
|
3
|
-
export
|
|
3
|
+
export type InitActionOptionsType = {
|
|
4
4
|
repositoryNames?: string[];
|
|
5
5
|
repositoryTypes?: string[];
|
|
6
6
|
verbose?: boolean;
|
package/Action/PruneAction.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ConfigType } from "../Config/Config";
|
|
|
2
2
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
3
3
|
import { IfRequireKeys } from "../util/ts-util";
|
|
4
4
|
import { SnapshotExtendedType, SnapshotsActionOptionsType } from "./SnapshotsAction";
|
|
5
|
-
export
|
|
5
|
+
export type PruneActionsOptionsType = {
|
|
6
6
|
ids?: string[];
|
|
7
7
|
packageNames?: string[];
|
|
8
8
|
repositoryNames?: string[];
|
|
@@ -21,7 +21,7 @@ export declare type PruneActionsOptionsType = {
|
|
|
21
21
|
longId?: boolean;
|
|
22
22
|
returnsAll?: boolean;
|
|
23
23
|
};
|
|
24
|
-
export
|
|
24
|
+
export type PruneResultType = {
|
|
25
25
|
total: number;
|
|
26
26
|
prune: number;
|
|
27
27
|
snapshots: (SnapshotExtendedType & {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ConfigType } from "../Config/Config";
|
|
2
2
|
import { PackageConfigType } from "../Config/PackageConfig";
|
|
3
3
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
4
|
-
import { TaskConfigType } from "../Config/TaskConfig";
|
|
5
4
|
import { AppError } from "../Error/AppError";
|
|
6
5
|
import { SnapshotResultType } from "../Repository/RepositoryAbstract";
|
|
7
6
|
import { RestoreSessionManager } from "../SessionManager/RestoreSessionManager";
|
|
7
|
+
import { TaskAbstract } from "../Task/TaskAbstract";
|
|
8
8
|
import { IfRequireKeys } from "../util/ts-util";
|
|
9
|
-
export
|
|
9
|
+
export type RestoreActionOptionsType = {
|
|
10
10
|
snapshotId: string;
|
|
11
11
|
tags?: string[];
|
|
12
12
|
packageNames?: string[];
|
|
@@ -16,10 +16,10 @@ export declare type RestoreActionOptionsType = {
|
|
|
16
16
|
repositoryTypes?: string[];
|
|
17
17
|
verbose?: boolean;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
type SnapshotType = SnapshotResultType & {
|
|
20
20
|
repositoryName: string;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
type SnapshotAndConfigType = [SnapshotType, PackageConfigType | null];
|
|
23
23
|
export declare class RestoreAction<TRequired extends boolean = true> {
|
|
24
24
|
readonly config: ConfigType;
|
|
25
25
|
readonly options: IfRequireKeys<TRequired, RestoreActionOptionsType>;
|
|
@@ -30,8 +30,14 @@ export declare class RestoreAction<TRequired extends boolean = true> {
|
|
|
30
30
|
protected init(session: RestoreSessionManager, snapshotId: string, snapshots: SnapshotAndConfigType[]): Promise<void>;
|
|
31
31
|
protected findSnapshots(): Promise<SnapshotType[]>;
|
|
32
32
|
protected groupSnapshots(snapshots: SnapshotType[]): SnapshotType[];
|
|
33
|
-
protected task(session: RestoreSessionManager, pkg: PackageConfigType, task:
|
|
34
|
-
|
|
33
|
+
protected task(session: RestoreSessionManager, pkg: PackageConfigType, task: TaskAbstract<any>, snapshot: SnapshotType, targetPath: string | undefined): Promise<{
|
|
34
|
+
error: boolean;
|
|
35
|
+
tmpDirs: string[];
|
|
36
|
+
}>;
|
|
37
|
+
protected restore(session: RestoreSessionManager, pkg: PackageConfigType, repo: RepositoryConfigType, snapshot: SnapshotType, targetPath: string | undefined): Promise<{
|
|
38
|
+
error: boolean;
|
|
39
|
+
tmpDirs: string[];
|
|
40
|
+
}>;
|
|
35
41
|
protected getError(pkg: PackageConfigType): AppError | null;
|
|
36
42
|
exec(session: RestoreSessionManager): Promise<boolean>;
|
|
37
43
|
}
|
package/Action/RestoreAction.js
CHANGED
|
@@ -91,7 +91,7 @@ class RestoreAction {
|
|
|
91
91
|
async task(session, pkg, task, snapshot, targetPath) {
|
|
92
92
|
const taskId = session.findTaskId({
|
|
93
93
|
packageName: pkg.name,
|
|
94
|
-
taskName: task.name,
|
|
94
|
+
taskName: pkg.task.name,
|
|
95
95
|
});
|
|
96
96
|
await session.startTask({
|
|
97
97
|
id: taskId,
|
|
@@ -105,8 +105,7 @@ class RestoreAction {
|
|
|
105
105
|
}
|
|
106
106
|
else {
|
|
107
107
|
try {
|
|
108
|
-
|
|
109
|
-
await taskInstance.onRestore({
|
|
108
|
+
await task.onRestore({
|
|
110
109
|
package: pkg,
|
|
111
110
|
options: this.options,
|
|
112
111
|
snapshot,
|
|
@@ -129,7 +128,10 @@ class RestoreAction {
|
|
|
129
128
|
id: taskId,
|
|
130
129
|
error: error?.stack,
|
|
131
130
|
});
|
|
132
|
-
return
|
|
131
|
+
return {
|
|
132
|
+
error: error ? false : true,
|
|
133
|
+
tmpDirs: task?.tmpDirs ?? [],
|
|
134
|
+
};
|
|
133
135
|
}
|
|
134
136
|
async restore(session, pkg, repo, snapshot, targetPath) {
|
|
135
137
|
const repositoryId = session.findRepositoryId({
|
|
@@ -140,6 +142,7 @@ class RestoreAction {
|
|
|
140
142
|
id: repositoryId,
|
|
141
143
|
});
|
|
142
144
|
let repoError;
|
|
145
|
+
let repoInstance;
|
|
143
146
|
try {
|
|
144
147
|
if (typeof pkg.restorePath !== "string")
|
|
145
148
|
throw new AppError_1.AppError("Restore path is not defined");
|
|
@@ -148,7 +151,7 @@ class RestoreAction {
|
|
|
148
151
|
throw new AppError_1.AppError(`Restore path is not empty: ${pkg.restorePath}`);
|
|
149
152
|
if (this.options.verbose)
|
|
150
153
|
(0, cli_util_1.logExec)(`restorePath=${pkg.restorePath}`);
|
|
151
|
-
|
|
154
|
+
repoInstance = (0, RepositoryFactory_1.RepositoryFactory)(repo);
|
|
152
155
|
await repoInstance.onRestore({
|
|
153
156
|
package: pkg,
|
|
154
157
|
targetPath,
|
|
@@ -179,7 +182,10 @@ class RestoreAction {
|
|
|
179
182
|
id: repositoryId,
|
|
180
183
|
error: repoError?.stack,
|
|
181
184
|
});
|
|
182
|
-
return
|
|
185
|
+
return {
|
|
186
|
+
error: repoError ? false : true,
|
|
187
|
+
tmpDirs: repoInstance?.tmpDirs || [],
|
|
188
|
+
};
|
|
183
189
|
}
|
|
184
190
|
getError(pkg) {
|
|
185
191
|
const taskErrors = this.taskErrors[pkg.name]?.length;
|
|
@@ -223,8 +229,9 @@ class RestoreAction {
|
|
|
223
229
|
});
|
|
224
230
|
await session.start({ id });
|
|
225
231
|
let targetPath;
|
|
232
|
+
let taskInstance;
|
|
226
233
|
if (pkg.task) {
|
|
227
|
-
|
|
234
|
+
taskInstance = (0, TaskFactory_1.TaskFactory)(pkg.task);
|
|
228
235
|
const result = await taskInstance.onBeforeRestore({
|
|
229
236
|
options: this.options,
|
|
230
237
|
package: pkg,
|
|
@@ -232,9 +239,16 @@ class RestoreAction {
|
|
|
232
239
|
});
|
|
233
240
|
targetPath = result?.targetPath;
|
|
234
241
|
}
|
|
235
|
-
await this.restore(session, pkg, repo, snapshot, targetPath);
|
|
236
|
-
if (
|
|
237
|
-
await this.task(session, pkg,
|
|
242
|
+
const { tmpDirs } = await this.restore(session, pkg, repo, snapshot, targetPath);
|
|
243
|
+
if (taskInstance) {
|
|
244
|
+
await this.task(session, pkg, taskInstance, snapshot, targetPath);
|
|
245
|
+
}
|
|
246
|
+
if (!this.options.verbose) {
|
|
247
|
+
await (0, fs_util_1.rmTmpDir)(taskInstance?.tmpDirs || []);
|
|
248
|
+
await (0, fs_util_1.rmTmpDir)(tmpDirs);
|
|
249
|
+
if (pkg.restorePath && (0, fs_util_1.isTmpDir)(pkg.restorePath))
|
|
250
|
+
await (0, fs_util_1.rmTmpDir)(pkg.restorePath);
|
|
251
|
+
}
|
|
238
252
|
const error = this.getError(pkg);
|
|
239
253
|
await session.end({
|
|
240
254
|
id,
|
|
@@ -2,7 +2,7 @@ import type { ConfigType } from "../Config/Config";
|
|
|
2
2
|
import { ReadDataType } from "../SessionDriver/SessionDriverAbstract";
|
|
3
3
|
import { RestoreSessionManager } from "../SessionManager/RestoreSessionManager";
|
|
4
4
|
import { IfRequireKeys } from "../util/ts-util";
|
|
5
|
-
export
|
|
5
|
+
export type RestoreSessionsActionOptionsType = ReadDataType & {
|
|
6
6
|
verbose?: boolean;
|
|
7
7
|
};
|
|
8
8
|
export declare class RestoreSessionsAction<TRequired extends boolean = true> {
|
|
@@ -2,8 +2,8 @@ import type { ConfigType } from "../Config/Config";
|
|
|
2
2
|
import { RepositoryConfigEnabledActionType } from "../Config/RepositoryConfig";
|
|
3
3
|
import { SnapshotResultType } from "../Repository/RepositoryAbstract";
|
|
4
4
|
import { IfRequireKeys } from "../util/ts-util";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type SnapshotGroupByType = keyof Pick<SnapshotExtendedType, "packageName" | "repositoryName" | "repositoryType">;
|
|
6
|
+
export type SnapshotsActionOptionsType = {
|
|
7
7
|
ids?: string[];
|
|
8
8
|
repositoryNames?: string[];
|
|
9
9
|
packageNames?: string[];
|
|
@@ -21,7 +21,7 @@ export declare type SnapshotsActionOptionsType = {
|
|
|
21
21
|
lastYearly?: number;
|
|
22
22
|
groupBy?: SnapshotGroupByType[];
|
|
23
23
|
};
|
|
24
|
-
export
|
|
24
|
+
export type SnapshotExtendedType = {
|
|
25
25
|
shortId: string;
|
|
26
26
|
repositoryName: string;
|
|
27
27
|
repositoryType: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
2
2
|
import { If } from "../util/ts-util";
|
|
3
3
|
import { CommandAbstract } from "./CommandAbstract";
|
|
4
|
-
export
|
|
4
|
+
export type BackupCommandOptionsType<TResolved = false> = {
|
|
5
5
|
package?: If<TResolved, string[]>;
|
|
6
6
|
packageTask?: If<TResolved, string[]>;
|
|
7
7
|
repository?: If<TResolved, string[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { If } from "../util/ts-util";
|
|
2
2
|
import { CommandAbstract } from "./CommandAbstract";
|
|
3
|
-
export
|
|
3
|
+
export type BackupSessionsCommandOptionsType<TResolved = false> = {
|
|
4
4
|
package?: If<TResolved, string[]>;
|
|
5
5
|
repository?: If<TResolved, string[]>;
|
|
6
6
|
tag?: If<TResolved, string[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CommandAbstract } from "./CommandAbstract";
|
|
2
|
-
export
|
|
2
|
+
export type CleanCacheCommandOptionsType<TResolved = false> = {};
|
|
3
3
|
export declare class CleanCacheCommand extends CommandAbstract<CleanCacheCommandOptionsType<false>, CleanCacheCommandOptionsType<true>> {
|
|
4
4
|
onOptions(): import("../util/cli-util").OptionsType<CleanCacheCommandOptionsType<false>, CleanCacheCommandOptionsType<true>>;
|
|
5
5
|
onExec(): Promise<number>;
|
|
@@ -2,14 +2,14 @@ import { ConfigType } from "../Config/Config";
|
|
|
2
2
|
import { FormatType } from "../util/DataFormat";
|
|
3
3
|
import { OptionsType } from "../util/cli-util";
|
|
4
4
|
import { SimilarObject } from "../util/ts-util";
|
|
5
|
-
export
|
|
5
|
+
export type GlobalOptionsType<TResolved = false> = {
|
|
6
6
|
config: string | ConfigType;
|
|
7
7
|
outputFormat?: FormatType;
|
|
8
8
|
verbose?: number;
|
|
9
9
|
progress?: "auto" | "plain" | "tty";
|
|
10
10
|
progressInterval?: number;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type CommandConstructorType<TUnresolvedOptions, TOptions extends SimilarObject<TUnresolvedOptions>> = {
|
|
13
13
|
new (globalOptions: GlobalOptionsType<true>, options: TOptions): CommandAbstract<TUnresolvedOptions, TOptions>;
|
|
14
14
|
};
|
|
15
15
|
export declare abstract class CommandAbstract<TUnresolvedOptions, TOptions extends SimilarObject<TUnresolvedOptions>> {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
2
2
|
import { If } from "../util/ts-util";
|
|
3
3
|
import { CommandAbstract } from "./CommandAbstract";
|
|
4
|
-
export
|
|
4
|
+
export type ConfigCommandOptionsType<TResolved = false> = {
|
|
5
5
|
package?: If<TResolved, string[]>;
|
|
6
6
|
packageTask?: If<TResolved, string[]>;
|
|
7
7
|
repository?: If<TResolved, string[]>;
|
|
8
8
|
repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type ConfigCommandLogType = {
|
|
11
11
|
packageName: string;
|
|
12
12
|
repositoryNames: string[];
|
|
13
13
|
taskName: string | undefined;
|
package/Command/InitCommand.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { InitAction } from "../Action/InitAction";
|
|
|
2
2
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
3
3
|
import { If, Unwrap } from "../util/ts-util";
|
|
4
4
|
import { CommandAbstract } from "./CommandAbstract";
|
|
5
|
-
export
|
|
5
|
+
export type InitCommandOptionsType<TResolved = false> = {
|
|
6
6
|
repository?: If<TResolved, string[]>;
|
|
7
7
|
repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type InitCommandLogType = Unwrap<InitAction["exec"]>;
|
|
10
10
|
export declare class InitCommand extends CommandAbstract<InitCommandOptionsType<false>, InitCommandOptionsType<true>> {
|
|
11
11
|
onOptions(): import("../util/cli-util").OptionsType<InitCommandOptionsType<false>, InitCommandOptionsType<true>>;
|
|
12
12
|
onExec(): Promise<number>;
|
|
@@ -2,7 +2,7 @@ import { SnapshotGroupByType } from "../Action/SnapshotsAction";
|
|
|
2
2
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
3
3
|
import { If } from "../util/ts-util";
|
|
4
4
|
import { CommandAbstract } from "./CommandAbstract";
|
|
5
|
-
export
|
|
5
|
+
export type PruneCommandOptionsType<TResolved = false> = {
|
|
6
6
|
id?: If<TResolved, string[]>;
|
|
7
7
|
longId?: boolean;
|
|
8
8
|
package?: If<TResolved, string[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
2
2
|
import { If } from "../util/ts-util";
|
|
3
3
|
import { CommandAbstract } from "./CommandAbstract";
|
|
4
|
-
export
|
|
4
|
+
export type RestoreCommandOptionsType<TResolved = false> = {
|
|
5
5
|
id: string;
|
|
6
6
|
package?: If<TResolved, string[]>;
|
|
7
7
|
packageTask?: If<TResolved, string[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { If } from "../util/ts-util";
|
|
2
2
|
import { CommandAbstract } from "./CommandAbstract";
|
|
3
|
-
export
|
|
3
|
+
export type RestoreSessionsCommandOptionsType<TResolved = false> = {
|
|
4
4
|
package?: If<TResolved, string[]>;
|
|
5
5
|
repository?: If<TResolved, string[]>;
|
|
6
6
|
tag?: If<TResolved, string[]>;
|
|
@@ -2,7 +2,7 @@ import { SnapshotsAction } from "../Action/SnapshotsAction";
|
|
|
2
2
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
3
3
|
import { If, Unwrap } from "../util/ts-util";
|
|
4
4
|
import { CommandAbstract } from "./CommandAbstract";
|
|
5
|
-
export
|
|
5
|
+
export type SnapshotsCommandOptionsType<TResolved = false> = {
|
|
6
6
|
id?: If<TResolved, string[]>;
|
|
7
7
|
package?: If<TResolved, string[]>;
|
|
8
8
|
packageTask?: If<TResolved, string[]>;
|
|
@@ -20,7 +20,7 @@ export declare type SnapshotsCommandOptionsType<TResolved = false> = {
|
|
|
20
20
|
groupBy?: If<TResolved, SnapshotsAction["options"]["groupBy"]>;
|
|
21
21
|
tag?: If<TResolved, string[]>;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type SnapshotsCommandLogType = Unwrap<SnapshotsAction["exec"]>;
|
|
24
24
|
export declare class SnapshotsCommand extends CommandAbstract<SnapshotsCommandOptionsType<false>, SnapshotsCommandOptionsType<true>> {
|
|
25
25
|
onOptions(): import("../util/cli-util").OptionsType<SnapshotsCommandOptionsType<false>, SnapshotsCommandOptionsType<true>>;
|
|
26
26
|
onExec(): Promise<number>;
|
|
@@ -12,7 +12,12 @@ const CommandAbstract_1 = require("./CommandAbstract");
|
|
|
12
12
|
const pretty_bytes_1 = __importDefault(require("pretty-bytes"));
|
|
13
13
|
class SnapshotsCommand extends CommandAbstract_1.CommandAbstract {
|
|
14
14
|
onOptions() {
|
|
15
|
-
const groupByValues = [
|
|
15
|
+
const groupByValues = [
|
|
16
|
+
"id",
|
|
17
|
+
"packageName",
|
|
18
|
+
"repositoryName",
|
|
19
|
+
"repositoryType",
|
|
20
|
+
];
|
|
16
21
|
return this.returnsOptions({
|
|
17
22
|
groupBy: {
|
|
18
23
|
option: "-g,--group-by <values>",
|
package/Config/Config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PackageConfigType } from "./PackageConfig";
|
|
2
2
|
import { RepositoryConfigType } from "./RepositoryConfig";
|
|
3
3
|
import type { JSONSchema7 } from "json-schema";
|
|
4
|
-
export
|
|
4
|
+
export type ConfigType = {
|
|
5
5
|
tempDir?: string;
|
|
6
6
|
repositories: RepositoryConfigType[];
|
|
7
7
|
packages: PackageConfigType[];
|
|
@@ -4,12 +4,12 @@ import type { TaskConfigType } from "./TaskConfig";
|
|
|
4
4
|
import { JSONSchema7 } from "json-schema";
|
|
5
5
|
export declare const packageConfigDefinition: JSONSchema7;
|
|
6
6
|
export declare const pathsObjectDefinition: JSONSchema7;
|
|
7
|
-
export
|
|
7
|
+
export type PathsObjectType = {
|
|
8
8
|
type: "spawn";
|
|
9
9
|
command: string;
|
|
10
10
|
args?: string[];
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type PackageConfigType = {
|
|
13
13
|
name: string;
|
|
14
14
|
enabled?: boolean;
|
|
15
15
|
task?: TaskConfigType;
|
|
@@ -3,7 +3,7 @@ import { GitPackageRepositoryConfigType, gitRepositoryName } from "../Repository
|
|
|
3
3
|
import { ResticPackageRepositoryConfigType, resticRepositoryName } from "../Repository/ResticRepository";
|
|
4
4
|
import type { JSONSchema7 } from "json-schema";
|
|
5
5
|
export declare const packageRepositoryConfigDefinition: JSONSchema7;
|
|
6
|
-
export
|
|
6
|
+
export type PackageRepositoryConfigType = {
|
|
7
7
|
names?: string[];
|
|
8
8
|
} & ({
|
|
9
9
|
type: typeof resticRepositoryName;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PruneActionsOptionsType } from "../Action/PruneAction";
|
|
2
2
|
import { JSONSchema7 } from "json-schema";
|
|
3
3
|
export declare const prunePolicyConfigDefinition: JSONSchema7;
|
|
4
|
-
export
|
|
4
|
+
export type PrunePolicyConfigType = Pick<PruneActionsOptionsType, "keepDaily" | "keepHourly" | "keepMinutely" | "keepLast" | "keepMonthly" | "keepWeekly" | "keepYearly" | "groupBy" | "tags">;
|
|
@@ -3,9 +3,9 @@ import { GitRepositoryConfigType, gitRepositoryName } from "../Repository/GitRep
|
|
|
3
3
|
import { ResticRepositoryConfigType, resticRepositoryName } from "../Repository/ResticRepository";
|
|
4
4
|
import type { JSONSchema7 } from "json-schema";
|
|
5
5
|
export declare const repositoryConfigDefinition: JSONSchema7;
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
6
|
+
export type RepositoryConfigTypeType = RepositoryConfigType["type"];
|
|
7
|
+
export type RepositoryConfigEnabledActionType = "backup" | "init" | "prune" | "restore" | "snapshots";
|
|
8
|
+
export type RepositoryConfigType = {
|
|
9
9
|
name: string;
|
|
10
10
|
mirrorRepoNames?: string[];
|
|
11
11
|
enabled?: boolean | {
|
package/Config/TaskConfig.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { PostgresqlDumpTaskConfigType, postgresqlDumpTaskName } from "../Task/Po
|
|
|
6
6
|
import { ScriptTaskConfigType, scriptTaskName } from "../Task/ScriptTask";
|
|
7
7
|
import { JSONSchema7 } from "json-schema";
|
|
8
8
|
export declare const taskConfigDefinition: JSONSchema7;
|
|
9
|
-
export
|
|
9
|
+
export type TaskConfigType = {
|
|
10
10
|
name: typeof gitTaskName;
|
|
11
11
|
config?: GitTaskConfigType;
|
|
12
12
|
} | {
|
|
@@ -20,7 +20,7 @@ export declare enum CommandEnum {
|
|
|
20
20
|
restoreSessions = "restore-sessions",
|
|
21
21
|
cleanCache = "clean-cache"
|
|
22
22
|
}
|
|
23
|
-
export
|
|
23
|
+
export type OptionsMapType = {
|
|
24
24
|
[CommandEnum.config]: ConfigCommandOptionsType;
|
|
25
25
|
[CommandEnum.init]: InitCommandOptionsType;
|
|
26
26
|
[CommandEnum.snapshots]: SnapshotsCommandOptionsType;
|
|
@@ -31,7 +31,7 @@ export declare type OptionsMapType = {
|
|
|
31
31
|
[CommandEnum.restoreSessions]: RestoreSessionsCommandOptionsType;
|
|
32
32
|
[CommandEnum.cleanCache]: CleanCacheActionOptionsType;
|
|
33
33
|
};
|
|
34
|
-
export
|
|
34
|
+
export type LogMapType = {
|
|
35
35
|
[CommandEnum.config]: ConfigCommandLogType;
|
|
36
36
|
[CommandEnum.init]: InitCommandLogType;
|
|
37
37
|
[CommandEnum.snapshots]: SnapshotsCommandLogType;
|