From 2401aead0bdbe67de0ec9ba31b5152da43ab32db Mon Sep 17 00:00:00 2001 From: amanmallsops Date: Thu, 18 Jan 2024 11:31:23 +0530 Subject: [PATCH 1/5] require changes done for backup and restore --- examples/complete/aws/main.tf | 5 +++-- helm/values/backup/values.yaml | 1 + main.tf | 1 + modules/backup/templates/cronjob.yaml | 2 ++ variables.tf | 3 ++- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/complete/aws/main.tf b/examples/complete/aws/main.tf index f349813..cc93ac0 100644 --- a/examples/complete/aws/main.tf +++ b/examples/complete/aws/main.tf @@ -64,14 +64,15 @@ 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/backup/" s3_bucket_region = "" cron_for_full_backup = "*/5 * * * *" } mysqldb_restore_enabled = true iam_role_arn_restore = module.aws.iam_role_arn_restore mysqldb_restore_config = { - bucket_uri = "s3://bucket_name/mysqldump_20230710_120501.zip" + bucket_uri = "s3://bucket_name/backup/mysqldump_20230710_120501.zip" file_name = "mysqldump_20230710_120501.zip" s3_bucket_region = "" } 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..9b71837 100644 --- a/modules/backup/templates/cronjob.yaml +++ b/modules/backup/templates/cronjob.yaml @@ -27,6 +27,8 @@ spec: 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" { From 683f50234fa33ba990e7a633515aeee6da973f15 Mon Sep 17 00:00:00 2001 From: amanmallsops Date: Thu, 18 Jan 2024 11:32:05 +0530 Subject: [PATCH 2/5] require changes done for backup and restore --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a314aa5..8ba22cd 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,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 | From cdc458e9a7dc6a62f138094ebf4b4e4e97f5dd31 Mon Sep 17 00:00:00 2001 From: amanmallsops Date: Thu, 18 Jan 2024 11:44:53 +0530 Subject: [PATCH 3/5] reqired changes done. --- examples/complete/aws/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/complete/aws/main.tf b/examples/complete/aws/main.tf index cc93ac0..b5acc13 100644 --- a/examples/complete/aws/main.tf +++ b/examples/complete/aws/main.tf @@ -65,14 +65,14 @@ module "mysql" { mysqldb_backup_enabled = true mysqldb_backup_config = { mysql_database_name = "" - bucket_uri = "s3://bucket_name/backup/" + bucket_uri = "s3://bucket_name/" s3_bucket_region = "" cron_for_full_backup = "*/5 * * * *" } mysqldb_restore_enabled = true iam_role_arn_restore = module.aws.iam_role_arn_restore mysqldb_restore_config = { - bucket_uri = "s3://bucket_name/backup/mysqldump_20230710_120501.zip" + bucket_uri = "s3://bucket_name/mysqldump_20230710_120501.zip" file_name = "mysqldump_20230710_120501.zip" s3_bucket_region = "" } From 9e1fbcba1f5ff5057231e06bfbfe02b6f8fac10f Mon Sep 17 00:00:00 2001 From: amanmallsops Date: Thu, 18 Jan 2024 19:59:44 +0530 Subject: [PATCH 4/5] require changes done --- modules/backup/templates/cronjob.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backup/templates/cronjob.yaml b/modules/backup/templates/cronjob.yaml index 9b71837..85d8cf2 100644 --- a/modules/backup/templates/cronjob.yaml +++ b/modules/backup/templates/cronjob.yaml @@ -20,7 +20,7 @@ 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 From 68fed2061a328df175cb7fcb05e11490b09db589 Mon Sep 17 00:00:00 2001 From: amanmallsops Date: Fri, 19 Jan 2024 16:36:07 +0530 Subject: [PATCH 5/5] required changes implemented --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8ba22cd..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 * * * *"