diff --git a/README.md b/README.md index a314aa5..4db01f4 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ module "mysql" { iam_role_arn_backup = module.aws.iam_role_arn_backup mysqldb_backup_enabled = true mysqldb_backup_config = { + mysql_database_name = "" bucket_uri = "s3://bucket_name" s3_bucket_region = "" cron_for_full_backup = "*/5 * * * *" @@ -165,7 +166,7 @@ No modules. | [iam\_role\_arn\_backup](#input\_iam\_role\_arn\_backup) | IAM role ARN for backup (AWS) | `string` | `""` | no | | [iam\_role\_arn\_restore](#input\_iam\_role\_arn\_restore) | IAM role ARN for restore (AWS) | `string` | `""` | no | | [metric\_exporter\_pasword](#input\_metric\_exporter\_pasword) | Metric exporter password for MongoDB | `string` | `""` | no | -| [mysqldb\_backup\_config](#input\_mysqldb\_backup\_config) | configuration options for MySQL database backups. It includes properties such as the S3 bucket URI, the S3 bucket region, and the cron expression for full backups. | `any` |
{
"bucket_uri": "",
"cron_for_full_backup": "",
"s3_bucket_region": ""
} | no |
+| [mysqldb\_backup\_config](#input\_mysqldb\_backup\_config) | configuration options for MySQL database backups. It includes properties such as the S3 bucket URI, the S3 bucket region, cron expression for full backups and the database name to take backup of particular database or if send empty it backup whole database | `any` | {
"bucket_uri": "",
"cron_for_full_backup": "",
"mysql_database_name": "",
"s3_bucket_region": ""
} | no |
| [mysqldb\_backup\_enabled](#input\_mysqldb\_backup\_enabled) | Specifies whether to enable backups for MySQL database. | `bool` | `false` | no |
| [mysqldb\_config](#input\_mysqldb\_config) | Specify the configuration settings for MySQL, including the name, environment, storage options, replication settings, and custom YAML values. | `any` | {
"architecture": "",
"custom_database": "",
"custom_user_username": "",
"environment": "",
"name": "",
"primary_db_volume_size": "",
"secondary_db_replica_count": 1,
"secondary_db_volume_size": "",
"storage_class_name": "",
"store_password_to_secret_manager": true,
"values_yaml": ""
} | no |
| [mysqldb\_custom\_credentials\_config](#input\_mysqldb\_custom\_credentials\_config) | Specify the configuration settings for MySQL to pass custom credentials during creation | `any` | {
"custom_user_password": "",
"custom_username": "",
"exporter_password": "",
"exporter_user": "",
"replication_password": "",
"replication_user": "",
"root_password": "",
"root_user": ""
} | no |
diff --git a/examples/complete/aws/main.tf b/examples/complete/aws/main.tf
index f349813..b5acc13 100644
--- a/examples/complete/aws/main.tf
+++ b/examples/complete/aws/main.tf
@@ -64,7 +64,8 @@ module "mysql" {
iam_role_arn_backup = module.aws.iam_role_arn_backup
mysqldb_backup_enabled = true
mysqldb_backup_config = {
- bucket_uri = "s3://bucket_name"
+ mysql_database_name = ""
+ bucket_uri = "s3://bucket_name/"
s3_bucket_region = ""
cron_for_full_backup = "*/5 * * * *"
}
diff --git a/helm/values/backup/values.yaml b/helm/values/backup/values.yaml
index 84e493a..a699792 100644
--- a/helm/values/backup/values.yaml
+++ b/helm/values/backup/values.yaml
@@ -3,6 +3,7 @@ backup:
bucket_uri: ${bucket_uri}
aws_default_region: ${s3_bucket_region}
cron_for_full_backup: "${cron_for_full_backup}"
+ database_name: "${mysql_database_name}"
annotations:
diff --git a/main.tf b/main.tf
index 4079229..05121c5 100644
--- a/main.tf
+++ b/main.tf
@@ -45,6 +45,7 @@ resource "helm_release" "mysqldb_backup" {
values = [
templatefile("${path.module}/helm/values/backup/values.yaml", {
bucket_uri = var.mysqldb_backup_config.bucket_uri,
+ mysql_database_name = var.bucket_provider_type == "s3" ? var.mysqldb_backup_config.mysql_database_name : "",
s3_bucket_region = var.bucket_provider_type == "s3" ? var.mysqldb_backup_config.s3_bucket_region : "",
cron_for_full_backup = var.mysqldb_backup_config.cron_for_full_backup,
custom_user_username = "root",
diff --git a/modules/backup/templates/cronjob.yaml b/modules/backup/templates/cronjob.yaml
index 9f4fc15..85d8cf2 100644
--- a/modules/backup/templates/cronjob.yaml
+++ b/modules/backup/templates/cronjob.yaml
@@ -20,13 +20,15 @@ spec:
serviceAccountName: sa-mysql-backup
containers:
- name: backup-mysqldb
- image: squareops/mysqldb-backup:v4
+ image: squareops/mysqldb-backup:v5
imagePullPolicy: Always
env:
- name: MYSQL_HOST
value: mysqldb-secondary-headless.{{ .Release.Namespace }}.svc.cluster.local
- name: MYSQL_USER
value: {{ .Values.auth.username }}
+ - name: DATABASES
+ value: {{ .Values.backup.database_name }}
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
diff --git a/variables.tf b/variables.tf
index 2420bbd..c45bbf6 100644
--- a/variables.tf
+++ b/variables.tf
@@ -66,8 +66,9 @@ variable "mysqldb_backup_config" {
bucket_uri = ""
s3_bucket_region = ""
cron_for_full_backup = ""
+ mysql_database_name = ""
}
- description = "configuration options for MySQL database backups. It includes properties such as the S3 bucket URI, the S3 bucket region, and the cron expression for full backups."
+ description = "configuration options for MySQL database backups. It includes properties such as the S3 bucket URI, the S3 bucket region, cron expression for full backups and the database name to take backup of particular database or if send empty it backup whole database "
}
variable "mysqldb_exporter_enabled" {