feat: replace mysqldump with mydumper and dump each table into own file

This commit is contained in:
Michael Reichenbach 2021-03-08 10:43:34 +01:00 committed by Silthus
parent b6a711a70d
commit d54013d700
2 changed files with 35 additions and 32 deletions

View File

@ -11,11 +11,11 @@ ADD https://github.com/itzg/rcon-cli/releases/download/${RCON_CLI_VERSION}/rcon-
RUN tar x -f /tmp/rcon-cli.tar.gz -C /opt/ && \
chmod +x /opt/rcon-cli
FROM restic/restic
RUN apk -U --no-cache add \
bash \
mydumper \
coreutils \
openssh-client \
python3 py3-pip \

View File

@ -35,27 +35,29 @@ class MariadbContainer(Container):
def dump_command(self) -> list:
"""list: create a dump command restic and use to send data through stdin"""
creds = self.get_credentials()
destination = self.backup_destination_path()
return [
"mysqldump",
f"--single-transaction",
f"--skip-lock-tables",
f"--host={creds['host']}",
f"--port={creds['port']}",
f"--user={creds['username']}",
"--all-databases",
"mydumper",
f"--user {creds['username']}",
f"--password {creds['password']}",
f"--host {creds['host']}",
f"--port {creds['port']}",
f"--outputdir {destination}",
"--no-views",
"--compress",
"--regex '^(?!(mysql\.))'"
]
def backup(self):
config = Config()
creds = self.get_credentials()
with utils.environment('MYSQL_PWD', creds['password']):
return restic.backup_from_stdin(
config.repository,
self.backup_destination_path(),
self.dump_command(),
tags=self.tags
)
commands.run(self.dump_command())
return restic.backup_files(
config.repository,
self.backup_destination_path(),
tags=self.tags
)
def backup_destination_path(self) -> str:
destination = Path("/databases")
@ -66,7 +68,6 @@ class MariadbContainer(Container):
destination /= project_name
destination /= self.service_name
destination /= "all_databases.sql"
return destination
@ -97,27 +98,29 @@ class MysqlContainer(Container):
def dump_command(self) -> list:
"""list: create a dump command restic and use to send data through stdin"""
creds = self.get_credentials()
destination = self.backup_destination_path()
return [
"mysqldump",
f"--single-transaction",
f"--skip-lock-tables",
f"--host={creds['host']}",
f"--port={creds['port']}",
f"--user={creds['username']}",
"--all-databases",
"mydumper",
f"--user {creds['username']}",
f"--password {creds['password']}",
f"--host {creds['host']}",
f"--port {creds['port']}",
f"--outputdir {destination}",
"--no-views",
"--compress",
"--regex '^(?!(mysql\.))'"
]
def backup(self):
config = Config()
creds = self.get_credentials()
with utils.environment('MYSQL_PWD', creds['password']):
return restic.backup_from_stdin(
config.repository,
self.backup_destination_path(),
self.dump_command(),
tags=self.tags
)
commands.run(self.dump_command())
return restic.backup_files(
config.repository,
self.backup_destination_path(),
tags=self.tags
)
def backup_destination_path(self) -> str:
destination = Path("/databases")