@highstate/restic 0.9.13 → 0.9.15
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/dist/highstate.manifest.json +2 -2
- package/dist/index.js +78 -38
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
- package/src/job-pair.ts +85 -43
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@highstate/restic",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -17,18 +17,19 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "highstate build"
|
|
20
|
+
"build": "highstate build",
|
|
21
|
+
"update-images": "../../scripts/update-images.sh ./assets/images.json"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@highstate/common": "^0.9.
|
|
24
|
-
"@highstate/k8s": "^0.9.
|
|
25
|
-
"@highstate/library": "^0.9.
|
|
26
|
-
"@highstate/pulumi": "^0.9.
|
|
24
|
+
"@highstate/common": "^0.9.15",
|
|
25
|
+
"@highstate/k8s": "^0.9.15",
|
|
26
|
+
"@highstate/library": "^0.9.15",
|
|
27
|
+
"@highstate/pulumi": "^0.9.15",
|
|
27
28
|
"@pulumi/kubernetes": "^4.18.0",
|
|
28
29
|
"remeda": "^2.21.0"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@highstate/cli": "^0.9.
|
|
32
|
+
"@highstate/cli": "^0.9.15"
|
|
32
33
|
},
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "f61b9905d4cd50511b03331411f42595403ebc06"
|
|
34
35
|
}
|
package/src/job-pair.ts
CHANGED
|
@@ -23,10 +23,12 @@ import {
|
|
|
23
23
|
type ComponentResourceOptions,
|
|
24
24
|
type Input,
|
|
25
25
|
type InputArray,
|
|
26
|
+
type InstanceTerminal,
|
|
26
27
|
type InstanceTrigger,
|
|
27
28
|
type InstanceTriggerInvocation,
|
|
28
29
|
} from "@highstate/pulumi"
|
|
29
30
|
import { text } from "@highstate/contract"
|
|
31
|
+
import * as images from "../assets/images.json"
|
|
30
32
|
import { backupEnvironment } from "./scripts"
|
|
31
33
|
|
|
32
34
|
export type BackupJobPairArgs = CommonArgs & {
|
|
@@ -123,6 +125,11 @@ export class BackupJobPair extends ComponentResource {
|
|
|
123
125
|
*/
|
|
124
126
|
readonly backupJob: Output<CronJob>
|
|
125
127
|
|
|
128
|
+
/**
|
|
129
|
+
* The full name of the Restic repository.
|
|
130
|
+
*/
|
|
131
|
+
readonly resticRepoPath: Output<string>
|
|
132
|
+
|
|
126
133
|
constructor(
|
|
127
134
|
private readonly name: string,
|
|
128
135
|
private readonly args: BackupJobPairArgs,
|
|
@@ -146,65 +153,71 @@ export class BackupJobPair extends ComponentResource {
|
|
|
146
153
|
)
|
|
147
154
|
})
|
|
148
155
|
|
|
149
|
-
|
|
150
|
-
const
|
|
156
|
+
this.resticRepoPath = output(args).apply(args => {
|
|
157
|
+
const relativePath = args.resticRepo.pathPattern
|
|
151
158
|
.replace(/\$clusterName/g, args.cluster.name)
|
|
152
159
|
.replace(/\$appName/g, name)
|
|
153
160
|
.replace(/\$unitName/g, getUnitInstanceName())
|
|
154
161
|
|
|
155
|
-
return {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
162
|
+
return `rclone:${args.resticRepo.remoteName}:${relativePath}`
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
const environment = output({ args, repoPath: this.resticRepoPath }).apply(
|
|
166
|
+
({ args, repoPath }) => {
|
|
167
|
+
return {
|
|
168
|
+
alpine: {
|
|
169
|
+
packages: ["rclone"],
|
|
170
|
+
},
|
|
159
171
|
|
|
160
|
-
|
|
161
|
-
|
|
172
|
+
ubuntu: {
|
|
173
|
+
preInstallPackages: ["curl", "unzip"],
|
|
162
174
|
|
|
163
|
-
|
|
164
|
-
|
|
175
|
+
preInstallScripts: {
|
|
176
|
+
"rclone.sh": text`
|
|
165
177
|
#!/bin/sh
|
|
166
178
|
set -e
|
|
167
179
|
|
|
168
180
|
curl https://rclone.org/install.sh | bash
|
|
169
181
|
`,
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
allowedEndpoints: ["rclone.org:443", "downloads.rclone.org:443"],
|
|
170
185
|
},
|
|
171
186
|
|
|
172
|
-
allowedEndpoints: [
|
|
173
|
-
|
|
187
|
+
allowedEndpoints: [
|
|
188
|
+
...(args.allowedEndpoints ?? []),
|
|
189
|
+
...(args.resticRepo.remoteEndpoints ?? []),
|
|
190
|
+
],
|
|
174
191
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
RESTIC_PASSWORD_FILE: "/credentials/password",
|
|
183
|
-
RESTIC_HOSTNAME: "default",
|
|
184
|
-
RCLONE_CONFIG: "/credentials/rclone.conf",
|
|
185
|
-
EXTRA_BACKUP_OPTIONS: args.backupOptions?.join(" "),
|
|
186
|
-
},
|
|
192
|
+
environment: {
|
|
193
|
+
RESTIC_REPOSITORY: repoPath,
|
|
194
|
+
RESTIC_PASSWORD_FILE: "/credentials/password",
|
|
195
|
+
RESTIC_HOSTNAME: "default",
|
|
196
|
+
RCLONE_CONFIG: "/credentials/rclone.conf",
|
|
197
|
+
EXTRA_BACKUP_OPTIONS: args.backupOptions?.join(" "),
|
|
198
|
+
},
|
|
187
199
|
|
|
188
|
-
|
|
200
|
+
volumes: [this.credentials, ...(args.volume ? [args.volume] : [])],
|
|
189
201
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
volumeMounts: [
|
|
203
|
+
{
|
|
204
|
+
volume: this.credentials,
|
|
205
|
+
mountPath: "/credentials",
|
|
206
|
+
readOnly: true,
|
|
207
|
+
},
|
|
208
|
+
...(args.volume
|
|
209
|
+
? [
|
|
210
|
+
{
|
|
211
|
+
volume: args.volume,
|
|
212
|
+
mountPath: "/data",
|
|
213
|
+
subPath: args.subPath,
|
|
214
|
+
},
|
|
215
|
+
]
|
|
216
|
+
: []),
|
|
217
|
+
],
|
|
218
|
+
} satisfies ScriptEnvironment
|
|
219
|
+
},
|
|
220
|
+
)
|
|
208
221
|
|
|
209
222
|
this.scriptBundle = output(args).apply(args => {
|
|
210
223
|
return new ScriptBundle(
|
|
@@ -291,6 +304,35 @@ export class BackupJobPair extends ComponentResource {
|
|
|
291
304
|
}
|
|
292
305
|
}
|
|
293
306
|
|
|
307
|
+
createTerminal(): InstanceTerminal {
|
|
308
|
+
return {
|
|
309
|
+
name: "restic",
|
|
310
|
+
title: "Restic",
|
|
311
|
+
description: "Manage Restic repository",
|
|
312
|
+
icon: "material-symbols:backup",
|
|
313
|
+
|
|
314
|
+
image: images["terminal-restic"].image,
|
|
315
|
+
command: ["bash", "/welcome.sh"],
|
|
316
|
+
|
|
317
|
+
files: {
|
|
318
|
+
"/welcome.sh": text`
|
|
319
|
+
echo "Use 'restic' to manage the repository."
|
|
320
|
+
echo
|
|
321
|
+
|
|
322
|
+
exec bash
|
|
323
|
+
`,
|
|
324
|
+
|
|
325
|
+
"/credentials/password": output(this.args).backupPassword,
|
|
326
|
+
"/root/.config/rclone/rclone.conf": output(this.args).resticRepo.rcloneConfig,
|
|
327
|
+
},
|
|
328
|
+
|
|
329
|
+
env: {
|
|
330
|
+
RESTIC_REPOSITORY: this.resticRepoPath,
|
|
331
|
+
RESTIC_PASSWORD_FILE: "/credentials/password",
|
|
332
|
+
},
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
294
336
|
private async createBackupOnDestroyJob(): Promise<void> {
|
|
295
337
|
new batch.v1.Job(
|
|
296
338
|
`${this.name}-backup-on-destroy`,
|