From a5091db50174ba7a5db561ca19485ed50fab36ae Mon Sep 17 00:00:00 2001
From: Einar Forselv <eforselv@gmail.com>
Date: Mon, 2 Dec 2019 22:53:00 +0100
Subject: [PATCH] Separate mariadb and mysql

---
 docker-compose.yaml                |  2 +-
 restic_volume_backup/cli.py        | 10 ++++++++++
 restic_volume_backup/containers.py |  5 +++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/docker-compose.yaml b/docker-compose.yaml
index 3e8cc60..15b8040 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -39,7 +39,7 @@ services:
   mariadb:
     image: mariadb:10
     labels:
-      restic-volume-backup.mysql: true
+      restic-volume-backup.mariadb: true
     environment:
       - MYSQL_ROOT_PASSWORD=my-secret-pw
       - MYSQL_DATABASE=mydb
diff --git a/restic_volume_backup/cli.py b/restic_volume_backup/cli.py
index 218ef5b..3756cc4 100644
--- a/restic_volume_backup/cli.py
+++ b/restic_volume_backup/cli.py
@@ -54,6 +54,16 @@ def status(config, containers):
                 creds['password'],
             )
 
+        if container.mariadb_backup_enabled:
+            logger.info(' -> mariadb %s', container.mysql_backup_enabled)
+            creds = container.get_mysql_credentials()
+            restic.ping_mysql(
+                creds['host'],
+                creds['port'],
+                creds['username'],
+                creds['password'],
+            )
+
     if len(backup_containers) == 0:
         logger.info("No containers in the project has 'restic-volume-backup.enabled' label")
 
diff --git a/restic_volume_backup/containers.py b/restic_volume_backup/containers.py
index 658651f..3e04215 100644
--- a/restic_volume_backup/containers.py
+++ b/restic_volume_backup/containers.py
@@ -75,6 +75,7 @@ class Container:
         return any([
             self.volume_backup_enabled,
             self.mysql_backup_enabled,
+            self.mariadb_backup_enabled,
             self.postgresql_backup_enabled,
         ])
 
@@ -86,6 +87,10 @@ class Container:
     def mysql_backup_enabled(self) -> bool:
         return utils.is_true(self.get_label('restic-volume-backup.mysql'))
 
+    @property
+    def mariadb_backup_enabled(self) -> bool:
+        return utils.is_true(self.get_label('restic-volume-backup.mariadb'))
+
     @property
     def postgresql_backup_enabled(self) -> bool:
         return utils.is_true(self.get_label('restic-volume-backup.postgresql'))