mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-08-07 00:23:20 +02:00
Add MySQL dump metadata.
This commit is contained in:
@@ -311,7 +311,7 @@ def collect_dumps_from_archive(
|
||||
|
||||
# No dumps metadata files were found, so for backwards compatibility, fall back to parsing the
|
||||
# paths of dumps found in the archive to get their respective dump metadata.
|
||||
logger.debug(f'Collecting database dumps from archive data source dump paths')
|
||||
logger.debug(f'Collecting database dumps from archive data source dump paths (fallback)')
|
||||
borgmatic_source_directory = str(
|
||||
pathlib.Path(borgmatic.config.paths.get_borgmatic_source_directory(config)),
|
||||
)
|
||||
|
||||
@@ -188,11 +188,12 @@ def dump_data_sources(
|
||||
'''
|
||||
dry_run_label = ' (dry run; not actually dumping anything)' if dry_run else ''
|
||||
processes = []
|
||||
dumps_metadata = []
|
||||
|
||||
logger.info(f'Dumping MySQL databases{dry_run_label}')
|
||||
dump_path = make_dump_path(borgmatic_runtime_directory)
|
||||
|
||||
for database in databases:
|
||||
dump_path = make_dump_path(borgmatic_runtime_directory)
|
||||
username = borgmatic.hooks.credential.parse.resolve_credential(
|
||||
database.get('username'),
|
||||
config,
|
||||
@@ -224,10 +225,19 @@ def dump_data_sources(
|
||||
|
||||
raise ValueError('Cannot find any MySQL databases to dump.')
|
||||
|
||||
|
||||
if database['name'] == 'all' and database.get('format'):
|
||||
for dump_name in dump_database_names:
|
||||
for database_name in dump_database_names:
|
||||
dumps_metadata.append(
|
||||
borgmatic.actions.restore.Dump(
|
||||
'mysql_databases',
|
||||
database_name,
|
||||
database.get('hostname'),
|
||||
database.get('port'),
|
||||
)
|
||||
)
|
||||
renamed_database = copy.copy(database)
|
||||
renamed_database['name'] = dump_name
|
||||
renamed_database['name'] = database_name
|
||||
processes.append(
|
||||
execute_dump_command(
|
||||
renamed_database,
|
||||
@@ -235,13 +245,21 @@ def dump_data_sources(
|
||||
username,
|
||||
password,
|
||||
dump_path,
|
||||
(dump_name,),
|
||||
(database_name,),
|
||||
environment,
|
||||
dry_run,
|
||||
dry_run_label,
|
||||
),
|
||||
)
|
||||
else:
|
||||
dumps_metadata.append(
|
||||
borgmatic.actions.restore.Dump(
|
||||
'mysql_databases',
|
||||
database['name'],
|
||||
database.get('hostname'),
|
||||
database.get('port'),
|
||||
)
|
||||
)
|
||||
processes.append(
|
||||
execute_dump_command(
|
||||
database,
|
||||
@@ -257,6 +275,9 @@ def dump_data_sources(
|
||||
)
|
||||
|
||||
if not dry_run:
|
||||
dump.write_data_source_dumps_metadata(
|
||||
borgmatic_runtime_directory, 'mysql_databases', dumps_metadata
|
||||
)
|
||||
patterns.append(
|
||||
borgmatic.borg.pattern.Pattern(
|
||||
os.path.join(borgmatic_runtime_directory, 'mysql_databases'),
|
||||
|
||||
Reference in New Issue
Block a user