PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
FIX (postgresql): Escape special characters in .pgpass file for authentication
kapawitc89c1f96543b
diff --git a/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go b/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.goindex f52c9021..87e0adf5 100644--- a/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go+++ b/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go@@ -719,11 +719,18 @@ func (uc *CreatePostgresqlBackupUsecase) createTempPgpassFile(return "", nil}+ // Escape special characters in password as per PostgreSQL .pgpass format+ // Per official PostgreSQL documentation: only backslash and colon need escaping+ escapedPassword := strings.NewReplacer(+ "\\", "\\\\",+ ":", "\\:",+ ).Replace(password)+pgpassContent := fmt.Sprintf("%s:%d:*:%s:%s",pgConfig.Host,pgConfig.Port,pgConfig.Username,- password,+ escapedPassword,)tempDir, err := os.MkdirTemp("", "pgpass")diff --git a/backend/internal/features/restores/usecases/postgresql/restore_backup_uc.go b/backend/internal/features/restores/usecases/postgresql/restore_backup_uc.goindex f19b23b7..6e06e792 100644--- a/backend/internal/features/restores/usecases/postgresql/restore_backup_uc.go+++ b/backend/internal/features/restores/usecases/postgresql/restore_backup_uc.go@@ -564,11 +564,18 @@ func (uc *RestorePostgresqlBackupUsecase) createTempPgpassFile(return "", nil}+ // Escape special characters in password as per PostgreSQL .pgpass format+ // Per official PostgreSQL documentation: only backslash and colon need escaping+ escapedPassword := strings.NewReplacer(+ "\\", "\\\\",+ ":", "\\:",+ ).Replace(password)+pgpassContent := fmt.Sprintf("%s:%d:*:%s:%s",pgConfig.Host,pgConfig.Port,pgConfig.Username,- password,+ escapedPassword,)tempDir, err := os.MkdirTemp("", "pgpass")