diff --git a/defaults/main.yml b/defaults/main.yml
index 6a767cf2a560861ffae81f44b4f9e7455a2ab8be..ed2595b904aeb0b3f0578da902f3def5b566c30c 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -42,3 +42,4 @@ borgbackup_use_msmtp: true
 borgbackup_email_from: "notifications@oh14.de"
 borgbackup_interval: "hourly"
 borgbackup_chunker_params: "19,23,21,4095"
+borgbackup_mariadb_enable: false
diff --git a/templates/config.yaml.j2 b/templates/config.yaml.j2
index 823675513b278b73103dd7831b170640ceca0e23..cd43b79fcd1bee29313e01547b23b6076ed4d95f 100644
--- a/templates/config.yaml.j2
+++ b/templates/config.yaml.j2
@@ -1,9 +1,6 @@
 location:
   # List of source directories to backup. Globs are expanded.
-  source_directories:
-  {% for item in borgbackup_source_dirs %}
-  - {{ item }}
-  {% endfor %}
+  source_directories:  {{ borgbackup_source_dirs | to_nice_yaml }}
 
   # Paths to local or remote repositories.
   repositories:
@@ -33,3 +30,12 @@ consistency:
   - repository
   - archives
   check_last: 3
+
+{% if borgbackup_mariadb_enable %}
+hooks:
+  mysql_databases:
+    - name: all
+      username: {{ borgbackup_mariadb_user }}
+      password: {{ borgbackup_mariadb_password }}
+      options: "--single-transaction --quick"
+{% endif %}