diff --git a/rattail_fabric2/mysql.py b/rattail_fabric2/mysql.py index cb14740..889fa7a 100644 --- a/rattail_fabric2/mysql.py +++ b/rattail_fabric2/mysql.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2020 Lance Edgar +# Copyright © 2010-2021 Lance Edgar # # This file is part of Rattail. # @@ -149,15 +149,17 @@ def script(c, path, database=''): c.sudo("bash -c 'mysql {} < {}'".format(database, path)) -def download_db(c, name, destination=None): +def download_db(c, name, destination=None, **kwargs): """ Download a database from the "current" server. """ if destination is None: destination = './{}.sql.gz'.format(name) + triggers = '--skip-triggers' if kwargs.get('skip_triggers') else '' + mysqldump = 'mysqldump {0} --result-file={1}.sql {1}'.format(triggers, name) # note, we force sudo "as root" to ensure -H flag is used # (which allows us to leverage /root/.my.cnf config file) - c.sudo('mysqldump --result-file={0}.sql {0}'.format(name), user='root') + c.sudo(mysqldump, user='root') c.sudo('gzip --force {}.sql'.format(name)) c.get('{}.sql.gz'.format(name), destination) c.sudo('rm {}.sql.gz'.format(name))