diff --git a/README.md b/README.md index c4bb73a5..69ee06b4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The Co-op Cloud utility belt 🎩🐇 -`abra` is a command-line tool for managing your own [Co-op Cloud](https://coopcloud.tech). It can provision new servers, create apps, deploy them, run backup and restore operations and a whole lot of other things. Please see [docs.coopcloud.tech](https://docs.coopcloud.tech) for more extensive documentation. +`abra` is a command-line tool for managing your own [Co-op Cloud](https://coopcloud.tech). It can provision new servers, create apps, deploy them and a whole lot of other things. Please see [docs.coopcloud.tech](https://docs.coopcloud.tech) for more extensive documentation. ## Quick install diff --git a/cli/app/app.go b/cli/app/app.go index 1d76b81b..830d45be 100644 --- a/cli/app/app.go +++ b/cli/app/app.go @@ -12,8 +12,8 @@ var AppCommand = cli.Command{ ArgsUsage: "", Description: ` This command provides all the functionality you need to manage the life cycle -of your apps. From initial deployment, day-2 operations (e.g. backup/restore) -to scaling apps up and spinning them down. +of your apps. From initial deployment to day-2 operations to scaling apps up +and spinning them down. `, Subcommands: []cli.Command{ appNewCommand, @@ -22,8 +22,6 @@ to scaling apps up and spinning them down. appDeployCommand, appUpgradeCommand, appUndeployCommand, - appBackupCommand, - appRestoreCommand, appRemoveCommand, appCheckCommand, appListCommand, diff --git a/cli/app/backup.go b/cli/app/backup.go deleted file mode 100644 index 96d1927b..00000000 --- a/cli/app/backup.go +++ /dev/null @@ -1,79 +0,0 @@ -package app - -import ( - "errors" - "fmt" - "io/ioutil" - "os" - "os/exec" - "path" - "strings" - - "coopcloud.tech/abra/cli/internal" - "coopcloud.tech/abra/pkg/autocomplete" - "coopcloud.tech/abra/pkg/config" - "github.com/sirupsen/logrus" - "github.com/urfave/cli" -) - -var backupAllServices bool -var backupAllServicesFlag = &cli.BoolFlag{ - Name: "all, a", - Destination: &backupAllServices, - Usage: "Backup all services", -} - -var appBackupCommand = cli.Command{ - Name: "backup", - Aliases: []string{"b"}, - Usage: "Backup an app", - Flags: []cli.Flag{ - internal.DebugFlag, - internal.NoInputFlag, - backupAllServicesFlag}, - Before: internal.SubCommandBefore, - ArgsUsage: "", - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) - - if c.Args().Get(1) != "" && backupAllServices { - internal.ShowSubcommandHelpAndError(c, errors.New("cannot use '' and '--all' together")) - } - - abraSh := path.Join(config.RECIPES_DIR, app.Type, "abra.sh") - if _, err := os.Stat(abraSh); err != nil { - if os.IsNotExist(err) { - logrus.Fatalf("%s does not exist?", abraSh) - } - logrus.Fatal(err) - } - - sourceCmd := fmt.Sprintf("source %s", abraSh) - - execCmd := "abra_backup" - if !backupAllServices { - serviceName := c.Args().Get(1) - if serviceName == "" { - internal.ShowSubcommandHelpAndError(c, errors.New("no service(s) target provided")) - } - execCmd = fmt.Sprintf("abra_backup_%s", serviceName) - } - - bytes, err := ioutil.ReadFile(abraSh) - if err != nil { - logrus.Fatal(err) - } - if !strings.Contains(string(bytes), execCmd) { - logrus.Fatalf("%s doesn't have a %s function", app.Type, execCmd) - } - - sourceAndExec := fmt.Sprintf("%s; %s", sourceCmd, execCmd) - cmd := exec.Command("bash", "-c", sourceAndExec) - if err := internal.RunCmd(cmd); err != nil { - logrus.Fatal(err) - } - - return nil - }, - BashComplete: autocomplete.AppNameComplete, -} diff --git a/cli/app/restore.go b/cli/app/restore.go deleted file mode 100644 index 0aed03e4..00000000 --- a/cli/app/restore.go +++ /dev/null @@ -1,82 +0,0 @@ -package app - -import ( - "errors" - "fmt" - "io/ioutil" - "os" - "os/exec" - "path" - "strings" - - "coopcloud.tech/abra/cli/internal" - "coopcloud.tech/abra/pkg/config" - "github.com/sirupsen/logrus" - "github.com/urfave/cli" -) - -var restoreAllServices bool -var restoreAllServicesFlag = &cli.BoolFlag{ - Name: "all, a", - Destination: &restoreAllServices, - Usage: "Restore all services", -} - -var appRestoreCommand = cli.Command{ - Name: "restore", - Aliases: []string{"rs"}, - Usage: "Restore an app from a backup", - Flags: []cli.Flag{ - internal.DebugFlag, - internal.NoInputFlag, - restoreAllServicesFlag, - }, - Before: internal.SubCommandBefore, - ArgsUsage: " []", - Action: func(c *cli.Context) error { - app := internal.ValidateApp(c) - - if len(c.Args()) > 1 && restoreAllServices { - internal.ShowSubcommandHelpAndError(c, errors.New("cannot use / and '--all' together")) - } - - abraSh := path.Join(config.RECIPES_DIR, app.Type, "abra.sh") - if _, err := os.Stat(abraSh); err != nil { - if os.IsNotExist(err) { - logrus.Fatalf("%s does not exist?", abraSh) - } - logrus.Fatal(err) - } - - sourceCmd := fmt.Sprintf("source %s", abraSh) - execCmd := "abra_restore" - if !restoreAllServices { - serviceName := c.Args().Get(1) - if serviceName == "" { - internal.ShowSubcommandHelpAndError(c, errors.New("no service(s) target provided")) - } - execCmd = fmt.Sprintf("abra_restore_%s", serviceName) - } - - bytes, err := ioutil.ReadFile(abraSh) - if err != nil { - logrus.Fatal(err) - } - if !strings.Contains(string(bytes), execCmd) { - logrus.Fatalf("%s doesn't have a %s function", app.Type, execCmd) - } - - backupFile := c.Args().Get(2) - if backupFile != "" { - execCmd = fmt.Sprintf("%s %s", execCmd, backupFile) - } - - sourceAndExec := fmt.Sprintf("%s; %s", sourceCmd, execCmd) - cmd := exec.Command("bash", "-c", sourceAndExec) - if err := internal.RunCmd(cmd); err != nil { - logrus.Fatal(err) - } - - return nil - }, -}