Private
(ctx context.Context, ns *docker.Namespace, cmd *cobra.Command, args []string)
| 28 | // Private |
| 29 | |
| 30 | func (r *restoreCommand) run(ctx context.Context, ns *docker.Namespace, cmd *cobra.Command, args []string) error { |
| 31 | filename := args[0] |
| 32 | |
| 33 | file, err := os.Open(filename) |
| 34 | if err != nil { |
| 35 | return fmt.Errorf("opening backup file: %w", err) |
| 36 | } |
| 37 | defer file.Close() |
| 38 | |
| 39 | if err := ns.Setup(ctx); err != nil { |
| 40 | return fmt.Errorf("setting up namespace: %w", err) |
| 41 | } |
| 42 | |
| 43 | app, err := ns.Restore(ctx, file) |
| 44 | if err != nil { |
| 45 | return fmt.Errorf("restoring application: %w", err) |
| 46 | } |
| 47 | |
| 48 | fmt.Printf("Restored %s from %s\n", app.Settings.Name, filename) |
| 49 | return nil |
| 50 | } |