-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix backup-ns cli nameing (fixes autocompletion scripts), add backup-…
…ns postgres info and backup-ns mysql info subcommands
- Loading branch information
Showing
5 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cmd | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/allaboutapps/backup-ns/internal/lib" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var mysqlInfoCmd = &cobra.Command{ | ||
Use: "info", | ||
Short: "Shows information about the mysql database backup state", | ||
Run: func(_ *cobra.Command, _ []string) { | ||
config := lib.LoadConfig() | ||
|
||
if !config.MySQL.Enabled { | ||
log.Fatal("BAK_DB_MYSQL=true must be set.") | ||
} | ||
|
||
runMySQLInfo(config) | ||
}, | ||
} | ||
|
||
func init() { | ||
mysqlCmd.AddCommand(mysqlInfoCmd) | ||
} | ||
|
||
func runMySQLInfo(config lib.Config) { | ||
if err := lib.EnsureResourceAvailable(config.Namespace, config.MySQL.ExecResource); err != nil { | ||
log.Fatal(err) | ||
} | ||
if err := lib.EnsureMySQLAvailable(config.Namespace, config.MySQL); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
timestamp, err := lib.GetRemoteFileTimestamp(config.Namespace, config.MySQL.ExecResource, config.MySQL.ExecContainer, config.MySQL.DumpFile) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
log.Printf("Last mysql dump in namespace='%s' was created at %s", config.Namespace, timestamp.UTC().Format("2006-01-02 15:04:05 MST")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cmd | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/allaboutapps/backup-ns/internal/lib" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var postgresInfoCmd = &cobra.Command{ | ||
Use: "info", | ||
Short: "Shows information about the postgres database backup state", | ||
Run: func(_ *cobra.Command, _ []string) { | ||
config := lib.LoadConfig() | ||
|
||
if !config.Postgres.Enabled { | ||
log.Fatal("BAK_DB_POSTGRES=true must be set.") | ||
} | ||
|
||
runPostgresInfo(config) | ||
}, | ||
} | ||
|
||
func init() { | ||
postgresCmd.AddCommand(postgresInfoCmd) | ||
} | ||
|
||
func runPostgresInfo(config lib.Config) { | ||
if err := lib.EnsureResourceAvailable(config.Namespace, config.Postgres.ExecResource); err != nil { | ||
log.Fatal(err) | ||
} | ||
if err := lib.EnsurePostgresAvailable(config.Namespace, config.Postgres); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
timestamp, err := lib.GetRemoteFileTimestamp(config.Namespace, config.Postgres.ExecResource, config.Postgres.ExecContainer, config.Postgres.DumpFile) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
log.Printf("Last postgres dump in namespace='%s' was created at %s", config.Namespace, timestamp.UTC().Format("2006-01-02 15:04:05 MST")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters