── storage restore ───────────────────────────────────────────────────────────
()
| 698 | // ── storage restore ─────────────────────────────────────────────────────────── |
| 699 | |
| 700 | func newStorageRestoreCmd() *cobra.Command { |
| 701 | cmd := &cobra.Command{ |
| 702 | Use: "restore <node> <storage> <volid> <vmid>", |
| 703 | Short: "Restore a guest from a backup", |
| 704 | Long: `Restore a guest from a vzdump backup volume. |
| 705 | |
| 706 | WARNING: This overwrites the target VMID's configuration and disk(s). |
| 707 | |
| 708 | Without --confirm, prints what would be restored and exits without making changes. |
| 709 | The guest type is inferred from the volid prefix (vzdump-qemu-* or vzdump-lxc-*); |
| 710 | use --type to override when inference fails.`, |
| 711 | Args: cobra.ExactArgs(4), |
| 712 | Example: ` # Dry-run preview (no changes made) |
| 713 | pvetui storage restore pve01 local local:backup/vzdump-qemu-100-2024.tar.zst 100 |
| 714 | |
| 715 | # Actually restore |
| 716 | pvetui storage restore pve01 local local:backup/vzdump-qemu-100-2024.tar.zst 100 --confirm |
| 717 | pvetui storage restore pve01 local local:backup/vzdump-lxc-101-2024.tar.zst 101 --confirm --type lxc`, |
| 718 | RunE: runStorageRestore, |
| 719 | } |
| 720 | |
| 721 | cmd.Flags().Bool("confirm", false, "Actually perform the restore (required; without it a dry-run summary is printed)") |
| 722 | cmd.Flags().String("type", "", "Guest type override: qemu or lxc (inferred from volid when omitted)") |
| 723 | cmd.Flags().StringP("output", "o", "json", "Output format: json or table") |
| 724 | addNoWaitFlag(cmd) |
| 725 | |
| 726 | cmd.ValidArgsFunction = completeStorageNames |
| 727 | |
| 728 | return cmd |
| 729 | } |
| 730 | |
| 731 | func runStorageRestore(cmd *cobra.Command, args []string) error { |
| 732 | ctx := context.Background() |
no test coverage detected