@shellus/way 0.6.0 → 0.6.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/README.md CHANGED
@@ -139,7 +139,7 @@ way backup data # 只备份 data 项目
139
139
  way backup data config # 备份多个项目
140
140
  way backup --dry-run # 模拟备份(不实际写入)
141
141
  way restore data --target /tmp/restore # 按规则恢复 data 项目
142
- way restore data --target /tmp/restore --dry-run # 模拟恢复
142
+ way restore data --host old-host --target /tmp/restore --dry-run # 从指定 host 模拟恢复
143
143
  way restore data --target /tmp/restore --delete # 删除目标中快照不存在的文件
144
144
  way gc # 按 retention 策略清理旧快照
145
145
  way gc --dry-run # 模拟清理(不实际删除)
@@ -326,14 +326,14 @@ way restore --target /tmp/restore
326
326
  way restore data --snapshot abc123 --target /tmp/restore
327
327
 
328
328
  # 预演恢复,不实际写入
329
- way restore data --target /tmp/restore --dry-run
329
+ way restore data --host old-host --target /tmp/restore --dry-run
330
330
 
331
331
  # 让目标目录与快照一致,先 dry-run 核对删除清单
332
- way restore data --target /tmp/restore --delete --dry-run
333
- way restore data --target /tmp/restore --delete
332
+ way restore data --host old-host --target /tmp/restore --delete --dry-run
333
+ way restore data --host old-host --target /tmp/restore --delete
334
334
  ```
335
335
 
336
- `way restore` 会为项目自动添加 `--tag=way:<project>` 和项目 `paths` 对应的 `--include` 参数。
336
+ `way restore` 会为项目自动添加 `--tag=way:<project>` 和项目 `paths` 对应的 `--include` 参数;传入 `--host` 时会只恢复指定 host 的快照。
337
337
 
338
338
  ### 4. 原始 restic 恢复
339
339
 
package/dist/cli.js CHANGED
@@ -84,9 +84,10 @@ function buildRestoreArgs(name, project, options) {
84
84
  const args = [
85
85
  "restore",
86
86
  options.snapshot || "latest",
87
- `--tag=way:${name}`,
88
- `--target=${options.target}`
87
+ `--tag=way:${name}`
89
88
  ];
89
+ if (options.host) args.push(`--host=${options.host}`);
90
+ args.push(`--target=${options.target}`);
90
91
  for (const path4 of project.paths) args.push(`--include=${path4}`);
91
92
  if (options.dryRun) args.push("--dry-run");
92
93
  if (options.delete) args.push("--delete");
@@ -193,6 +194,7 @@ async function restore(options) {
193
194
  const args = buildRestoreArgs(projectName, project, {
194
195
  target: options.target,
195
196
  snapshot: options.snapshot,
197
+ host: options.host,
196
198
  dryRun: options.dryRun,
197
199
  delete: options.delete,
198
200
  verbose: options.verbose
@@ -357,7 +359,7 @@ async function daemon(options) {
357
359
 
358
360
  // src/cli.ts
359
361
  var program = new Command();
360
- program.name("way").version("0.6.0").description("\u7B56\u7565\u5907\u4EFD\u5DE5\u5177 - \u57FA\u4E8E restic \u7684\u7B56\u7565\u5C01\u88C5").option("--remote <name>", "\u6307\u5B9A\u4ED3\u5E93", "default").addHelpText("after", `
362
+ program.name("way").version("0.6.1").description("\u7B56\u7565\u5907\u4EFD\u5DE5\u5177 - \u57FA\u4E8E restic \u7684\u7B56\u7565\u5C01\u88C5").option("--remote <name>", "\u6307\u5B9A\u4ED3\u5E93", "default").addHelpText("after", `
361
363
  \u793A\u4F8B:
362
364
  $ way backup \u6267\u884C\u6240\u6709\u9879\u76EE\u5907\u4EFD
363
365
  $ way backup data \u53EA\u5907\u4EFD data \u9879\u76EE
@@ -380,13 +382,14 @@ program.command("backup [projects...]").description("\u6309 rules.yaml \u6267\u8
380
382
  const extraArgs = collectBackupArgs(this);
381
383
  await backup({ remote, projects: projects.filter((p) => !p.startsWith("-")), extraArgs, dryRun });
382
384
  });
383
- program.command("restore [projects...]").description("\u6309 rules.yaml \u6062\u590D\u9879\u76EE").requiredOption("--target <dir>", "\u6062\u590D\u76EE\u6807\u76EE\u5F55").option("--snapshot <snapshot>", "\u5FEB\u7167 ID \u6216 latest", "latest").option("--dry-run", "\u6A21\u62DF\u6062\u590D\uFF08\u4E0D\u5B9E\u9645\u5199\u5165\uFF09").option("--delete", "\u5220\u9664\u76EE\u6807\u4E2D\u5FEB\u7167\u4E0D\u5B58\u5728\u7684\u6587\u4EF6").option("-v, --verbose", "\u663E\u793A\u8BE6\u7EC6\u6062\u590D\u8BA1\u5212\uFF08\u4F20\u9012 --verbose=2 \u7ED9 restic\uFF09").action(async function(projects, cmdOptions) {
385
+ program.command("restore [projects...]").description("\u6309 rules.yaml \u6062\u590D\u9879\u76EE").requiredOption("--target <dir>", "\u6062\u590D\u76EE\u6807\u76EE\u5F55").option("--snapshot <snapshot>", "\u5FEB\u7167 ID \u6216 latest", "latest").option("--host <host>", "\u53EA\u6062\u590D\u6307\u5B9A host \u7684\u5FEB\u7167").option("--dry-run", "\u6A21\u62DF\u6062\u590D\uFF08\u4E0D\u5B9E\u9645\u5199\u5165\uFF09").option("--delete", "\u5220\u9664\u76EE\u6807\u4E2D\u5FEB\u7167\u4E0D\u5B58\u5728\u7684\u6587\u4EF6").option("-v, --verbose", "\u663E\u793A\u8BE6\u7EC6\u6062\u590D\u8BA1\u5212\uFF08\u4F20\u9012 --verbose=2 \u7ED9 restic\uFF09").action(async function(projects, cmdOptions) {
384
386
  const remote = this.parent.opts().remote;
385
387
  await restore({
386
388
  remote,
387
389
  projects,
388
390
  target: cmdOptions.target,
389
391
  snapshot: cmdOptions.snapshot,
392
+ host: cmdOptions.host,
390
393
  dryRun: cmdOptions.dryRun,
391
394
  delete: cmdOptions.delete,
392
395
  verbose: cmdOptions.verbose
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shellus/way",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "将备份作为持续运营的项目,而非一次性任务。基于 restic 的策略封装。",
5
5
  "type": "module",
6
6
  "bin": {