Let a postgres db download exclude some tables
This commit is contained in:
parent
440130439e
commit
190a8318cc
|
@ -143,7 +143,7 @@ def drop_db(name, checkfirst=True):
|
||||||
sudo('sudo -u postgres dropdb {0}'.format(name), shell=False)
|
sudo('sudo -u postgres dropdb {0}'.format(name), shell=False)
|
||||||
|
|
||||||
|
|
||||||
def download_db(name, destination=None, port=None):
|
def download_db(name, destination=None, port=None, exclude_tables=None):
|
||||||
"""
|
"""
|
||||||
Download a database from the "current" server.
|
Download a database from the "current" server.
|
||||||
"""
|
"""
|
||||||
|
@ -151,9 +151,10 @@ def download_db(name, destination=None, port=None):
|
||||||
destination = './{0}.sql.gz'.format(name)
|
destination = './{0}.sql.gz'.format(name)
|
||||||
run('touch {0}.sql'.format(name))
|
run('touch {0}.sql'.format(name))
|
||||||
run('chmod 0666 {0}.sql'.format(name))
|
run('chmod 0666 {0}.sql'.format(name))
|
||||||
sudo('sudo -u postgres pg_dump {port} --file={name}.sql {name}'.format(
|
sudo('sudo -u postgres pg_dump {port} {exclude_tables} --file={name}.sql {name}'.format(
|
||||||
name=name,
|
name=name,
|
||||||
port='--port={}'.format(port) if port else '',
|
port='--port={}'.format(port) if port else '',
|
||||||
|
exclude_tables='--exclude-table-data={}'.format(exclude_tables) if exclude_tables else '',
|
||||||
), shell=False)
|
), shell=False)
|
||||||
run('gzip --force {0}.sql'.format(name))
|
run('gzip --force {0}.sql'.format(name))
|
||||||
get('{0}.sql.gz'.format(name), destination)
|
get('{0}.sql.gz'.format(name), destination)
|
||||||
|
|
Loading…
Reference in a new issue