From bd97e903e33e7e8cf1b1907ef6c46ef938ad2630 Mon Sep 17 00:00:00 2001
From: Einar Forselv <eforselv@gmail.com>
Date: Tue, 3 Dec 2019 05:11:24 +0100
Subject: [PATCH] Add mysql backup methods

---
 restic_volume_backup/containers_db.py | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/restic_volume_backup/containers_db.py b/restic_volume_backup/containers_db.py
index 7a7e683..decb1b5 100644
--- a/restic_volume_backup/containers_db.py
+++ b/restic_volume_backup/containers_db.py
@@ -44,7 +44,7 @@ class MariadbContainer(Container):
         config = Config()
         return restic.backup_from_stdin(
             config.repository,
-            f'/backup/{self.service_name}',
+            f'/backup/{self.service_name}/all_databases.sql',
             self.dump_command(),
         )
 
@@ -73,10 +73,23 @@ class MysqlContainer(Container):
 
     def dump_command(self) -> list:
         """list: create a dump command restic and use to send data through stdin"""
-        raise NotImplementedError("Base container class don't implement this")
+        creds = self.get_credentials()
+        return [
+            "mysqldump",
+            f"--host={creds['host']}",
+            f"--port={creds['port']}",
+            f"--user={creds['username']}",
+            f"--password={creds['password']}",
+            "--all-databases",
+        ]
 
     def backup(self):
-        print("SKIPPING")
+        config = Config()
+        return restic.backup_from_stdin(
+            config.repository,
+            f'/backup/{self.service_name}/all_databases.sql',
+            self.dump_command(),
+        )
 
 
 class PostgresContainer(Container):