Separate mariadb and mysql

This commit is contained in:
Einar Forselv 2019-12-02 22:53:00 +01:00
parent 123f863b51
commit a5091db501
3 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -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")

View File

@ -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'))