mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-05 16:15:56 +00:00
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
|
|
"github.com/pilosa/pilosa/ctl"
|
|
)
|
|
|
|
var restorer = ctl.NewRestoreCommand(os.Stdin, os.Stdout, os.Stderr)
|
|
|
|
var restoreCmd = &cobra.Command{
|
|
Use: "restore",
|
|
Short: "Restore data to pilosa from a backup file.",
|
|
Long: `
|
|
Restores a frame to the cluster from a backup file.
|
|
`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if err := restorer.Run(context.Background()); err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
restoreCmd.Flags().StringVarP(&restorer.Host, "host", "", "localhost:15000", "host:port of Pilosa.")
|
|
restoreCmd.Flags().StringVarP(&restorer.Database, "database", "d", "", "Pilosa database to restore into.")
|
|
restoreCmd.Flags().StringVarP(&restorer.Frame, "frame", "f", "", "Frame to restore into.")
|
|
restoreCmd.Flags().StringVarP(&restorer.Path, "input-file", "i", "", "File to restore from.")
|
|
|
|
err := viper.BindPFlags(restoreCmd.Flags())
|
|
if err != nil {
|
|
log.Fatalf("Error binding restore flags: %v", err)
|
|
}
|
|
|
|
RootCmd.AddCommand(restoreCmd)
|
|
}
|