Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 * * * *"
Expand Down Expand Up @@ -165,7 +166,7 @@ No modules.
| <a name="input_iam_role_arn_backup"></a> [iam\_role\_arn\_backup](#input\_iam\_role\_arn\_backup) | IAM role ARN for backup (AWS) | `string` | `""` | no |
| <a name="input_iam_role_arn_restore"></a> [iam\_role\_arn\_restore](#input\_iam\_role\_arn\_restore) | IAM role ARN for restore (AWS) | `string` | `""` | no |
| <a name="input_metric_exporter_pasword"></a> [metric\_exporter\_pasword](#input\_metric\_exporter\_pasword) | Metric exporter password for MongoDB | `string` | `""` | no |
| <a name="input_mysqldb_backup_config"></a> [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` | <pre>{<br> "bucket_uri": "",<br> "cron_for_full_backup": "",<br> "s3_bucket_region": ""<br>}</pre> | no |
| <a name="input_mysqldb_backup_config"></a> [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` | <pre>{<br> "bucket_uri": "",<br> "cron_for_full_backup": "",<br> "mysql_database_name": "",<br> "s3_bucket_region": ""<br>}</pre> | no |
| <a name="input_mysqldb_backup_enabled"></a> [mysqldb\_backup\_enabled](#input\_mysqldb\_backup\_enabled) | Specifies whether to enable backups for MySQL database. | `bool` | `false` | no |
| <a name="input_mysqldb_config"></a> [mysqldb\_config](#input\_mysqldb\_config) | Specify the configuration settings for MySQL, including the name, environment, storage options, replication settings, and custom YAML values. | `any` | <pre>{<br> "architecture": "",<br> "custom_database": "",<br> "custom_user_username": "",<br> "environment": "",<br> "name": "",<br> "primary_db_volume_size": "",<br> "secondary_db_replica_count": 1,<br> "secondary_db_volume_size": "",<br> "storage_class_name": "",<br> "store_password_to_secret_manager": true,<br> "values_yaml": ""<br>}</pre> | no |
| <a name="input_mysqldb_custom_credentials_config"></a> [mysqldb\_custom\_credentials\_config](#input\_mysqldb\_custom\_credentials\_config) | Specify the configuration settings for MySQL to pass custom credentials during creation | `any` | <pre>{<br> "custom_user_password": "",<br> "custom_username": "",<br> "exporter_password": "",<br> "exporter_user": "",<br> "replication_password": "",<br> "replication_user": "",<br> "root_password": "",<br> "root_user": ""<br>}</pre> | no |
Expand Down
3 changes: 2 additions & 1 deletion examples/complete/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 * * * *"
}
Expand Down
1 change: 1 addition & 0 deletions helm/values/backup/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion modules/backup/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down