From 4e16823072a8386a94c42de3dc19c5ee0fd3333c Mon Sep 17 00:00:00 2001 From: Jonas Kaninda Date: Tue, 20 Feb 2024 07:55:55 +0100 Subject: [PATCH] refactor: refactoring of code --- pkg/backup.go | 11 +++++------ utils/constant.go | 6 ------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/pkg/backup.go b/pkg/backup.go index 99c1a41..5021d00 100644 --- a/pkg/backup.go +++ b/pkg/backup.go @@ -154,11 +154,10 @@ func BackupDatabase(disableCompression bool, prune bool, keepLast int) { } utils.Done("Database has been backed up") - //Delete old backup - if prune { - deleteOldBackup(keepLast) - } - + } + //Delete old backup + if prune { + deleteOldBackup(keepLast) } historyFile, err := os.OpenFile(fmt.Sprintf("%s/history.txt", storagePath), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) @@ -191,7 +190,7 @@ func deleteOldBackup(keepLast int) { if err != nil { utils.Fatal("Error:", err) } else { - utils.Done("File", filePath, "deleted successfully") + utils.Done("File ", filePath, " deleted successfully") } return err } diff --git a/utils/constant.go b/utils/constant.go index 8b96812..c0d4e92 100644 --- a/utils/constant.go +++ b/utils/constant.go @@ -1,11 +1,5 @@ package utils -const Notice = "Please remove --operation flag.\n" + - "Use: \n" + - "- backup for database backup operation [eg: bkup backup -d database_name ...]\n" + - "- restore for database restore operation [eg. bkup restore -d database_name ...]\n" + - "Example: bkup backup --storage s3 ...( instead of < bkup --operation backup >)\n" + - "We are sorry for this inconvenient\n" const RestoreExample = "pg-bkup restore --dbname database --file db_20231219_022941.sql.gz\n" + "bkup restore --dbname database --storage s3 --path /custom-path --file db_20231219_022941.sql.gz" const BackupExample = "pg-bkup backup --dbname database --disable-compression\n" +