Page MenuHomePhabricator

sre.mysql.clone*: use online backups instead of filesystem transfer
Open, MediumPublic

Description

The clone cookbooks stop the MariaDB instance on the source, which is not necessary as transferpy supports online backups via maria-backup.

An example on the command line:

sudo transfer.py --type xtrabackup --compress --verbose db1176.eqiad.wmnet:/run/mysqld/mysqld.sock db2230.codfw.wmnet:/srv/sqldata

An (untested) snippet for Python:

backup_options = dict(transferpy.transfer.parse_configurations(transferpy.transfer.CONFIG_FILE))
backup_options["encrypt"] = True
backup_options["type"] = "xtrabackup"

if self.spicerack.dry_run:
    self.log.info(
        "Dry-run detected, would have executed xtrabackup from %s to %s using: %s",
        source_host,
        target_host,
        backup_options,
    )
    return True

for status in Transferer(
    source_host, "/run/mysqld/mysqld.sock", [target_host], ["/srv/sqldata"], backup_options
).run():
    if status != 0:
        raise RestoreError("Failed to successfully complete the restore")