restore

package
v0.1.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Cmd = &cobra.Command{
		Use:   "restore [flags] dumpId|latest",
		Args:  cobra.ExactArgs(1),
		Short: "restore dump with ID or the latest to the target database",
		Run: func(cmd *cobra.Command, args []string) {

			if err := logger.SetLogLevel(Config.Log.Level, Config.Log.Format); err != nil {
				log.Fatal().Err(err).Msg("fatal")
			}

			ctx, cancel := context.WithCancel(context.Background())
			defer cancel()
			st, err := builder.GetStorage(ctx, &Config.Storage, &Config.Log)
			if err != nil {
				log.Fatal().Err(err).Msg("fatal")
			}

			dumpId, err := getDumpId(ctx, st, args[0])
			if err != nil {
				log.Fatal().Err(err).Msg("")
			}

			st = st.SubStorage(dumpId, true)

			restore := cmdInternals.NewRestore(
				Config.Common.PgBinPath, st, &Config.Restore.PgRestoreOptions, Config.Restore.Scripts,
				Config.Common.TempDirectory,
			)

			log.Info().
				Str("dumpId", dumpId).
				Msgf("restoring dump")
			if err := restore.Run(ctx); err != nil {
				log.Fatal().Err(err).Msg("fatal")
			}
		},
	}
	Config = pgDomains.NewConfig()
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL