mirror of
https://github.com/jkaninda/mysql-bkup.git
synced 2025-12-06 13:39:41 +01:00
Add SSH storage, add database backup encrypt and decrypt
This commit is contained in:
@@ -21,8 +21,8 @@ var BackupCmd = &cobra.Command{
|
||||
|
||||
func init() {
|
||||
//Backup
|
||||
BackupCmd.PersistentFlags().StringP("mode", "m", "default", "Set execution mode. default or scheduled")
|
||||
BackupCmd.PersistentFlags().StringP("period", "", "0 1 * * *", "Set schedule period time")
|
||||
BackupCmd.PersistentFlags().StringP("mode", "m", "default", "Execution mode. default or scheduled")
|
||||
BackupCmd.PersistentFlags().StringP("period", "", "0 1 * * *", "Schedule period time")
|
||||
BackupCmd.PersistentFlags().BoolP("prune", "", false, "Delete old backup, default disabled")
|
||||
BackupCmd.PersistentFlags().IntP("keep-last", "", 7, "Delete files created more than specified days ago, default 7 days")
|
||||
BackupCmd.PersistentFlags().BoolP("disable-compression", "", false, "Disable backup compression")
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/jkaninda/mysql-bkup/utils"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var HistoryCmd = &cobra.Command{
|
||||
Use: "history",
|
||||
Short: "Show the history of backup",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
utils.ShowHistory()
|
||||
},
|
||||
}
|
||||
12
cmd/root.go
12
cmd/root.go
@@ -19,7 +19,6 @@ var rootCmd = &cobra.Command{
|
||||
Version: appVersion,
|
||||
}
|
||||
var operation = ""
|
||||
var s3Path = "/mysql-bkup"
|
||||
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||
@@ -31,16 +30,13 @@ func Execute() {
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().StringP("storage", "s", "local", "Set storage. local or s3")
|
||||
rootCmd.PersistentFlags().StringP("path", "P", s3Path, "Set s3 path, without file name. for S3 storage only")
|
||||
rootCmd.PersistentFlags().StringP("dbname", "d", "", "Set database name")
|
||||
rootCmd.PersistentFlags().IntP("timeout", "t", 30, "Set timeout")
|
||||
rootCmd.PersistentFlags().IntP("port", "p", 3306, "Set database port")
|
||||
rootCmd.PersistentFlags().StringP("storage", "s", "local", "Storage. local or s3")
|
||||
rootCmd.PersistentFlags().StringP("path", "P", "", "AWS S3 path without file name. eg: /custom_path or ssh remote path `/home/foo/backup`")
|
||||
rootCmd.PersistentFlags().StringP("dbname", "d", "", "Database name")
|
||||
rootCmd.PersistentFlags().IntP("port", "p", 3306, "Database port")
|
||||
rootCmd.PersistentFlags().StringVarP(&operation, "operation", "o", "", "Set operation, for old version only")
|
||||
|
||||
rootCmd.AddCommand(VersionCmd)
|
||||
rootCmd.AddCommand(BackupCmd)
|
||||
rootCmd.AddCommand(RestoreCmd)
|
||||
rootCmd.AddCommand(S3MountCmd)
|
||||
rootCmd.AddCommand(HistoryCmd)
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/jkaninda/mysql-bkup/pkg"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var S3MountCmd = &cobra.Command{
|
||||
Use: "s3mount",
|
||||
Short: "Mount AWS S3 storage",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
pkg.S3Mount()
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user