Compare commits

..

9 Commits

Author SHA1 Message Date
dabba2050a Merge pull request #110 from jkaninda/refactor
chore: remove os.kill.signal
2024-10-05 10:42:55 +02:00
Jonas Kaninda
47e1ac407b chore: remove os.kill.signal 2024-10-05 10:41:46 +02:00
28f6ed3a82 Merge pull request #109 from jkaninda/refactor
fix: logging time
2024-10-05 10:40:11 +02:00
Jonas Kaninda
504926c7cd fix: logging time 2024-10-05 10:39:49 +02:00
737f473f92 Merge pull request #108 from jkaninda/refactor
Refactor
2024-10-03 18:19:12 +02:00
Jonas Kaninda
300d2a8205 chore: remove testDatabaseConnection function for scheduled mode 2024-10-03 18:18:47 +02:00
Jonas Kaninda
a4ad0502cf chore: add storage type alt for smallcase and uppercase 2024-10-03 18:17:48 +02:00
f344867edf Merge pull request #107 from jkaninda/refactor
docs: update configuration reference
2024-10-02 04:26:05 +02:00
Jonas Kaninda
d774584f64 docs: update configuration reference 2024-10-02 04:25:35 +02:00
4 changed files with 15 additions and 14 deletions

View File

@@ -47,16 +47,17 @@ Backup, restore and migrate targets, schedule and retention are configured using
| AWS_BUCKET_NAME | Optional, required for S3 storage | AWS S3 Bucket Name | | AWS_BUCKET_NAME | Optional, required for S3 storage | AWS S3 Bucket Name |
| AWS_REGION | Optional, required for S3 storage | AWS Region | | AWS_REGION | Optional, required for S3 storage | AWS Region |
| AWS_DISABLE_SSL | Optional, required for S3 storage | Disable SSL | | AWS_DISABLE_SSL | Optional, required for S3 storage | Disable SSL |
| AWS_FORCE_PATH_STYLE | Optional, required for S3 storage | Force path style |
| FILE_NAME | Optional if it was provided from the --file flag | Database file to restore (extensions: .sql, .sql.gz) | | FILE_NAME | Optional if it was provided from the --file flag | Database file to restore (extensions: .sql, .sql.gz) |
| GPG_PASSPHRASE | Optional, required to encrypt and restore backup | GPG passphrase | | GPG_PASSPHRASE | Optional, required to encrypt and restore backup | GPG passphrase |
| BACKUP_CRON_EXPRESSION | Optional if it was provided from the `--cron-expression` flag | Backup cron expression for docker in scheduled mode | | BACKUP_CRON_EXPRESSION | Optional if it was provided from the `--cron-expression` flag | Backup cron expression for docker in scheduled mode |
| SSH_HOST_NAME | Optional, required for SSH storage | ssh remote hostname or ip | | SSH_HOST | Optional, required for SSH storage | ssh remote hostname or ip |
| SSH_USER | Optional, required for SSH storage | ssh remote user | | SSH_USER | Optional, required for SSH storage | ssh remote user |
| SSH_PASSWORD | Optional, required for SSH storage | ssh remote user's password | | SSH_PASSWORD | Optional, required for SSH storage | ssh remote user's password |
| SSH_IDENTIFY_FILE | Optional, required for SSH storage | ssh remote user's private key | | SSH_IDENTIFY_FILE | Optional, required for SSH storage | ssh remote user's private key |
| SSH_PORT | Optional, required for SSH storage | ssh remote server port | | SSH_PORT | Optional, required for SSH storage | ssh remote server port |
| REMOTE_PATH | Optional, required for SSH or FTP storage | remote path (/home/toto/backup) | | REMOTE_PATH | Optional, required for SSH or FTP storage | remote path (/home/toto/backup) |
| FTP_HOST_NAME | Optional, required for FTP storage | FTP host name | | FTP_HOST | Optional, required for FTP storage | FTP host name |
| FTP_PORT | Optional, required for FTP storage | FTP server port number | | FTP_PORT | Optional, required for FTP storage | FTP server port number |
| FTP_USER | Optional, required for FTP storage | FTP user | | FTP_USER | Optional, required for FTP storage | FTP user |
| FTP_PASSWORD | Optional, required for FTP storage | FTP user password | | FTP_PASSWORD | Optional, required for FTP storage | FTP user password |

View File

@@ -42,8 +42,6 @@ func scheduledMode(db *dbConfig, config *BackupConfig) {
utils.Info("Backup cron expression: %s", config.cronExpression) utils.Info("Backup cron expression: %s", config.cronExpression)
utils.Info("Storage type %s ", config.storage) utils.Info("Storage type %s ", config.storage)
//Test database connexion
testDatabaseConnection(db)
//Test backup //Test backup
utils.Info("Testing backup configurations...") utils.Info("Testing backup configurations...")
BackupTask(db, config) BackupTask(db, config)
@@ -75,11 +73,11 @@ func BackupTask(db *dbConfig, config *BackupConfig) {
switch config.storage { switch config.storage {
case "local": case "local":
localBackup(db, config) localBackup(db, config)
case "s3": case "s3", "S3":
s3Backup(db, config) s3Backup(db, config)
case "ssh", "remote": case "ssh", "SSH", "remote":
sshBackup(db, config) sshBackup(db, config)
case "ftp": case "ftp", "FTP":
ftpBackup(db, config) ftpBackup(db, config)
default: default:
localBackup(db, config) localBackup(db, config)

View File

@@ -21,15 +21,15 @@ func StartRestore(cmd *cobra.Command) {
restoreConf := initRestoreConfig(cmd) restoreConf := initRestoreConfig(cmd)
switch restoreConf.storage { switch restoreConf.storage {
case "s3":
restoreFromS3(dbConf, restoreConf.file, restoreConf.bucket, restoreConf.s3Path)
case "local": case "local":
utils.Info("Restore database from local") utils.Info("Restore database from local")
copyToTmp(storagePath, restoreConf.file) copyToTmp(storagePath, restoreConf.file)
RestoreDatabase(dbConf, restoreConf.file) RestoreDatabase(dbConf, restoreConf.file)
case "ssh": case "s3", "S3":
restoreFromS3(dbConf, restoreConf.file, restoreConf.bucket, restoreConf.s3Path)
case "ssh", "SSH":
restoreFromRemote(dbConf, restoreConf.file, restoreConf.remotePath) restoreFromRemote(dbConf, restoreConf.file, restoreConf.remotePath)
case "ftp": case "ftp", "FTP":
restoreFromFTP(dbConf, restoreConf.file, restoreConf.remotePath) restoreFromFTP(dbConf, restoreConf.file, restoreConf.remotePath)
default: default:
utils.Info("Restore database from local") utils.Info("Restore database from local")

View File

@@ -12,9 +12,8 @@ import (
"time" "time"
) )
var currentTime = time.Now().Format("2006/01/02 15:04:05")
func Info(msg string, args ...any) { func Info(msg string, args ...any) {
var currentTime = time.Now().Format("2006/01/02 15:04:05")
formattedMessage := fmt.Sprintf(msg, args...) formattedMessage := fmt.Sprintf(msg, args...)
if len(args) == 0 { if len(args) == 0 {
fmt.Printf("%s INFO: %s\n", currentTime, msg) fmt.Printf("%s INFO: %s\n", currentTime, msg)
@@ -25,6 +24,7 @@ func Info(msg string, args ...any) {
// Warn warning message // Warn warning message
func Warn(msg string, args ...any) { func Warn(msg string, args ...any) {
var currentTime = time.Now().Format("2006/01/02 15:04:05")
formattedMessage := fmt.Sprintf(msg, args...) formattedMessage := fmt.Sprintf(msg, args...)
if len(args) == 0 { if len(args) == 0 {
fmt.Printf("%s WARN: %s\n", currentTime, msg) fmt.Printf("%s WARN: %s\n", currentTime, msg)
@@ -33,6 +33,7 @@ func Warn(msg string, args ...any) {
} }
} }
func Error(msg string, args ...any) { func Error(msg string, args ...any) {
var currentTime = time.Now().Format("2006/01/02 15:04:05")
formattedMessage := fmt.Sprintf(msg, args...) formattedMessage := fmt.Sprintf(msg, args...)
if len(args) == 0 { if len(args) == 0 {
fmt.Printf("%s ERROR: %s\n", currentTime, msg) fmt.Printf("%s ERROR: %s\n", currentTime, msg)
@@ -41,6 +42,7 @@ func Error(msg string, args ...any) {
} }
} }
func Done(msg string, args ...any) { func Done(msg string, args ...any) {
var currentTime = time.Now().Format("2006/01/02 15:04:05")
formattedMessage := fmt.Sprintf(msg, args...) formattedMessage := fmt.Sprintf(msg, args...)
if len(args) == 0 { if len(args) == 0 {
fmt.Printf("%s INFO: %s\n", currentTime, msg) fmt.Printf("%s INFO: %s\n", currentTime, msg)
@@ -51,6 +53,7 @@ func Done(msg string, args ...any) {
// Fatal logs an error message and exits the program // Fatal logs an error message and exits the program
func Fatal(msg string, args ...any) { func Fatal(msg string, args ...any) {
var currentTime = time.Now().Format("2006/01/02 15:04:05")
// Fatal logs an error message and exits the program. // Fatal logs an error message and exits the program.
formattedMessage := fmt.Sprintf(msg, args...) formattedMessage := fmt.Sprintf(msg, args...)
if len(args) == 0 { if len(args) == 0 {
@@ -63,5 +66,4 @@ func Fatal(msg string, args ...any) {
} }
os.Exit(1) os.Exit(1)
os.Kill.Signal()
} }