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/ && \ RUN tar x -f /tmp/rcon-cli.tar.gz -C /opt/ && \
chmod +x /opt/rcon-cli chmod +x /opt/rcon-cli
FROM restic/restic FROM restic/restic
RUN apk -U --no-cache add \ RUN apk -U --no-cache add \
bash \ bash \
mydumper \
coreutils \ coreutils \
openssh-client \ openssh-client \
python3 py3-pip \ python3 py3-pip \

View file

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