diff --git a/restic_compose_backup/commands.py b/restic_compose_backup/commands.py index fad7947..8773b58 100644 --- a/restic_compose_backup/commands.py +++ b/restic_compose_backup/commands.py @@ -9,7 +9,7 @@ def test(): return run_command(['ls', '/volumes']) -def ping_mysql(host, port, username, password) -> int: +def ping_mysql(host, port, username) -> int: """Check if the mysql is up and can be reached""" return run([ 'mysqladmin', @@ -20,11 +20,10 @@ def ping_mysql(host, port, username, password) -> int: port, '--user', username, - f'--password={password}', ]) -def ping_mariadb(host, port, username, password) -> int: +def ping_mariadb(host, port, username): #, password) -> int: """Check if the mariadb is up and can be reached""" return run([ 'mysqladmin', @@ -35,7 +34,6 @@ def ping_mariadb(host, port, username, password) -> int: port, '--user', username, - f'--password={password}', ]) diff --git a/restic_compose_backup/containers_db.py b/restic_compose_backup/containers_db.py index 813f641..5ad3ce0 100644 --- a/restic_compose_backup/containers_db.py +++ b/restic_compose_backup/containers_db.py @@ -22,12 +22,13 @@ class MariadbContainer(Container): def ping(self) -> bool: """Check the availability of the service""" creds = self.get_credentials() - return commands.ping_mysql( - creds['host'], - creds['port'], - creds['username'], - creds['password'], - ) + + with utils.environment('MYSQL_PWD', creds['password']): + return commands.ping_mariadb( + creds['host'], + creds['port'], + creds['username'], + ) def dump_command(self) -> list: """list: create a dump command restic and use to send data through stdin""" @@ -67,12 +68,13 @@ class MysqlContainer(Container): def ping(self) -> bool: """Check the availability of the service""" creds = self.get_credentials() - return commands.ping_mysql( - creds['host'], - creds['port'], - creds['username'], - creds['password'], - ) + + with utils.environment('MYSQL_PWD', creds['password']): + return commands.ping_mysql( + creds['host'], + creds['port'], + creds['username'], + ) def dump_command(self) -> list: """list: create a dump command restic and use to send data through stdin"""