feat: replace mysqldump with mydumper and dump each table into own file
This commit is contained in:
parent
b6a711a70d
commit
d54013d700
2 changed files with 35 additions and 32 deletions
|
@ -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 \
|
||||||
|
|
|
@ -35,27 +35,29 @@ 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(
|
|
||||||
config.repository,
|
return restic.backup_files(
|
||||||
self.backup_destination_path(),
|
config.repository,
|
||||||
self.dump_command(),
|
self.backup_destination_path(),
|
||||||
tags=self.tags
|
tags=self.tags
|
||||||
)
|
)
|
||||||
|
|
||||||
def backup_destination_path(self) -> str:
|
def backup_destination_path(self) -> str:
|
||||||
destination = Path("/databases")
|
destination = Path("/databases")
|
||||||
|
@ -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,27 +98,29 @@ 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(
|
|
||||||
config.repository,
|
return restic.backup_files(
|
||||||
self.backup_destination_path(),
|
config.repository,
|
||||||
self.dump_command(),
|
self.backup_destination_path(),
|
||||||
tags=self.tags
|
tags=self.tags
|
||||||
)
|
)
|
||||||
|
|
||||||
def backup_destination_path(self) -> str:
|
def backup_destination_path(self) -> str:
|
||||||
destination = Path("/databases")
|
destination = Path("/databases")
|
||||||
|
|
Loading…
Add table
Reference in a new issue