Skip to content

Commit 2401aea

Browse files
require changes done for backup and restore
1 parent 437b290 commit 2401aea

File tree

5 files changed

+9
-3
lines changed

5 files changed

+9
-3
lines changed

examples/complete/aws/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ module "mysql" {
6464
iam_role_arn_backup = module.aws.iam_role_arn_backup
6565
mysqldb_backup_enabled = true
6666
mysqldb_backup_config = {
67-
bucket_uri = "s3://bucket_name"
67+
mysql_database_name = ""
68+
bucket_uri = "s3://bucket_name/backup/"
6869
s3_bucket_region = ""
6970
cron_for_full_backup = "*/5 * * * *"
7071
}
7172
mysqldb_restore_enabled = true
7273
iam_role_arn_restore = module.aws.iam_role_arn_restore
7374
mysqldb_restore_config = {
74-
bucket_uri = "s3://bucket_name/mysqldump_20230710_120501.zip"
75+
bucket_uri = "s3://bucket_name/backup/mysqldump_20230710_120501.zip"
7576
file_name = "mysqldump_20230710_120501.zip"
7677
s3_bucket_region = ""
7778
}

helm/values/backup/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ backup:
33
bucket_uri: ${bucket_uri}
44
aws_default_region: ${s3_bucket_region}
55
cron_for_full_backup: "${cron_for_full_backup}"
6+
database_name: "${mysql_database_name}"
67

78

89
annotations:

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ resource "helm_release" "mysqldb_backup" {
4545
values = [
4646
templatefile("${path.module}/helm/values/backup/values.yaml", {
4747
bucket_uri = var.mysqldb_backup_config.bucket_uri,
48+
mysql_database_name = var.bucket_provider_type == "s3" ? var.mysqldb_backup_config.mysql_database_name : "",
4849
s3_bucket_region = var.bucket_provider_type == "s3" ? var.mysqldb_backup_config.s3_bucket_region : "",
4950
cron_for_full_backup = var.mysqldb_backup_config.cron_for_full_backup,
5051
custom_user_username = "root",

modules/backup/templates/cronjob.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ spec:
2727
value: mysqldb-secondary-headless.{{ .Release.Namespace }}.svc.cluster.local
2828
- name: MYSQL_USER
2929
value: {{ .Values.auth.username }}
30+
- name: DATABASES
31+
value: {{ .Values.backup.database_name }}
3032
- name: MYSQL_PASSWORD
3133
valueFrom:
3234
secretKeyRef:

variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ variable "mysqldb_backup_config" {
6666
bucket_uri = ""
6767
s3_bucket_region = ""
6868
cron_for_full_backup = ""
69+
mysql_database_name = ""
6970
}
70-
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."
71+
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 "
7172
}
7273

7374
variable "mysqldb_exporter_enabled" {

0 commit comments

Comments
 (0)