@ps-aux/nodebup 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cli/app.js
CHANGED
@@ -101,14 +101,22 @@ const createApp = () => _nclif.CliApp.of({
|
|
101
101
|
|
102
102
|
exports.createApp = createApp;
|
103
103
|
const restic = (0, _nclif.cmdGroup)({
|
104
|
+
options: singleStorageOptions,
|
104
105
|
commands: {
|
105
106
|
'init-repo': (0, _nclif.cmd)({
|
106
|
-
options: singleStorageOptions,
|
107
107
|
run: (_, c) => c.get(_ResticController.ResticController).initRepo()
|
108
108
|
}),
|
109
109
|
snapshots: (0, _nclif.cmd)({
|
110
|
-
options: singleStorageOptions,
|
111
110
|
run: (_, c, p) => c.get(_ResticController.ResticController).listSnapshots(p.stdout)
|
111
|
+
}),
|
112
|
+
cmd: (0, _nclif.cmd)({
|
113
|
+
positionals: [{
|
114
|
+
name: 'cmd',
|
115
|
+
required: true
|
116
|
+
}],
|
117
|
+
run: ({
|
118
|
+
cmd
|
119
|
+
}, c, p) => c.get(_ResticController.ResticController).runResticCmd(cmd, p.stdout)
|
112
120
|
})
|
113
121
|
}
|
114
122
|
});
|
@@ -126,9 +134,11 @@ const pg = (0, _nclif.cmdGroup)({
|
|
126
134
|
}],
|
127
135
|
commands: {
|
128
136
|
backup: (0, _nclif.cmd)({
|
137
|
+
options: backupOptions,
|
129
138
|
run: (inp, c) => c.get(_PgBackupController.PgBackupController).backup(inp)
|
130
139
|
}),
|
131
140
|
restore: (0, _nclif.cmd)({
|
141
|
+
options: restoreOptions,
|
132
142
|
run: (inp, c) => c.get(_PgBackupController.PgBackupController).restore(inp)
|
133
143
|
})
|
134
144
|
}
|
@@ -34,6 +34,12 @@ class ResticClient {
|
|
34
34
|
});
|
35
35
|
});
|
36
36
|
|
37
|
+
_defineProperty(this, "runCmd", cmd => {
|
38
|
+
return this.shell.execAndReturnBuffer(`restic ${cmd}`, {
|
39
|
+
env: this.env()
|
40
|
+
});
|
41
|
+
});
|
42
|
+
|
37
43
|
_defineProperty(this, "backup", (cwd, from, tags = []) => {
|
38
44
|
this.log.debug(`Running backup for repo=${this.url}`);
|
39
45
|
let cmd = `restic backup ${from.str()}`;
|
@@ -56,12 +62,12 @@ class ResticClient {
|
|
56
62
|
_defineProperty(this, "forget", () => {
|
57
63
|
this.log.debug(`Pruning repo=${this.url}`);
|
58
64
|
const cfg = {
|
59
|
-
hourly:
|
65
|
+
hourly: 6,
|
60
66
|
daily: 7,
|
61
67
|
weekly: 8,
|
62
|
-
monthly:
|
68
|
+
monthly: 12
|
63
69
|
};
|
64
|
-
this.shell.exec(`restic forget --prune ` + `--
|
70
|
+
this.shell.exec(`restic forget --prune ` + `--group-by tags ` + // The paths are often different when using tmp dirs
|
65
71
|
`--keep-hourly ${cfg.hourly} --keep-daily ${cfg.daily} ` + `--keep-weekly ${cfg.weekly} --keep-monthly ${cfg.monthly}`, {
|
66
72
|
env: this.env()
|
67
73
|
});
|
@@ -36,11 +36,12 @@ let ResticController = (_dec = (0, _inversify.injectable)(), _dec2 = function (t
|
|
36
36
|
_defineProperty(this, "client", () => {
|
37
37
|
const props = this.storageConfigProvider.provide();
|
38
38
|
if (props.type !== _types.StorageType.Restic) throw new Error('Storage is not Restic storage');
|
39
|
-
this.log.info('Initializing repo', props.repo);
|
40
39
|
return this.restFact.createClient(props);
|
41
40
|
});
|
42
41
|
|
43
42
|
_defineProperty(this, "initRepo", () => {
|
43
|
+
const props = this.storageConfigProvider.provide();
|
44
|
+
this.log.info(`Initializing Restic repo ${props.repo}`);
|
44
45
|
this.client().prepareRepo();
|
45
46
|
});
|
46
47
|
|
@@ -48,6 +49,11 @@ let ResticController = (_dec = (0, _inversify.injectable)(), _dec2 = function (t
|
|
48
49
|
const res = this.client().snapshots();
|
49
50
|
print(JSON.stringify(res, null, 4));
|
50
51
|
});
|
52
|
+
|
53
|
+
_defineProperty(this, "runResticCmd", (cmd, print) => {
|
54
|
+
const res = this.client().runCmd(cmd);
|
55
|
+
print(res.toString());
|
56
|
+
});
|
51
57
|
}
|
52
58
|
|
53
59
|
}) || _class) || _class) || _class) || _class);
|