fix go lint
Some checks failed
Build / docker (push) Failing after 8s

This commit is contained in:
2025-01-26 13:54:41 +01:00
parent fc028a2c55
commit 75b809511e
8 changed files with 14 additions and 15 deletions

View File

@@ -27,6 +27,7 @@ linters:
- gosimple
- govet
- ineffassign
# - lll
- misspell
- nakedret
- prealloc

View File

@@ -44,7 +44,7 @@ var BackupCmd = &cobra.Command{
}
func init() {
//Backup
// Backup
BackupCmd.PersistentFlags().StringP("storage", "s", "local", "Define storage: local, s3, ssh, ftp, azure")
BackupCmd.PersistentFlags().StringP("path", "P", "", "Storage path without file name. e.g: /custom_path or ssh remote path `/home/foo/backup`")
BackupCmd.PersistentFlags().StringP("cron-expression", "e", "", "Backup cron expression (e.g., `0 0 * * *` or `@daily`)")

View File

@@ -46,7 +46,7 @@ var RestoreCmd = &cobra.Command{
}
func init() {
//Restore
// Restore
RestoreCmd.PersistentFlags().StringP("file", "f", "", "File name of database")
RestoreCmd.PersistentFlags().StringP("storage", "s", "local", "Define storage: local, s3, ssh, ftp")
RestoreCmd.PersistentFlags().StringP("path", "P", "", "AWS S3 path without file name. eg: /custom_path or ssh remote path `/home/foo/backup`")

View File

@@ -38,7 +38,6 @@ var rootCmd = &cobra.Command{
Example: utils.MainExample,
Version: appVersion,
}
var operation = ""
// 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.

View File

@@ -207,7 +207,7 @@ func BackupDatabase(db *dbConfig, backupFileName string, disableCompression bool
}
err = testDatabaseConnection(db)
if err != nil {
return fmt.Errorf(err.Error())
return fmt.Errorf("failed to connect to the database: %v", err)
}
// Backup Database database
utils.Info("Backing up database...")
@@ -354,11 +354,11 @@ func recoverMode(err error, msg string) {
if err != nil {
if backupRescueMode {
utils.NotifyError(fmt.Sprintf("%s : %v", msg, err))
utils.Error(msg)
utils.Error("Error: %s", msg)
utils.Error("Backup rescue mode is enabled")
utils.Error("Backup will continue")
} else {
utils.Error(msg)
utils.Error("Error: %s", msg)
utils.Fatal("Error: %v", err)
}
}

View File

@@ -51,7 +51,10 @@ func StartMigration(cmd *cobra.Command) {
conf := &RestoreConfig{}
conf.file = backupFileName
// Backup source Database
BackupDatabase(dbConf, backupFileName, true)
err := BackupDatabase(dbConf, backupFileName, true)
if err != nil {
utils.Fatal("Error backing up database: %s", err)
}
// Restore source database into target database
utils.Info("Restoring [%s] database into [%s] database...", dbConf.dbName, targetDbConf.targetDbName)
RestoreDatabase(&newDbConfig, conf)

View File

@@ -118,7 +118,10 @@ func RestoreDatabase(db *dbConfig, conf *RestoreConfig) {
if err != nil {
return
}
testDatabaseConnection(db)
err = testDatabaseConnection(db)
if err != nil {
utils.Fatal("Error connecting to the database %v", err)
}
utils.Info("Restoring database...")
extension := filepath.Ext(filepath.Join(tmpPath, conf.file))

View File

@@ -62,13 +62,6 @@ var tdbRVars = []string{
var dbConf *dbConfig
var targetDbConf *targetDbConfig
// sshVars Required environment variables for SSH remote server storage
var sshVars = []string{
"SSH_USER",
"SSH_HOST_NAME",
"SSH_PORT",
"REMOTE_PATH",
}
var ftpVars = []string{
"FTP_HOST_NAME",
"FTP_USER",