Add a couple more options for rsync()
sometimes you just need something different to happen..
This commit is contained in:
parent
47bc4ce01d
commit
88e92588f2
|
@ -352,13 +352,21 @@ def make_deploy(deploy_path, last_segment='deploy'):
|
||||||
return Deployer(deploy_path, last_segment)
|
return Deployer(deploy_path, last_segment)
|
||||||
|
|
||||||
|
|
||||||
def rsync(c, host, *paths):
|
def rsync(c, host, *paths, files=False, target=None):
|
||||||
"""
|
"""
|
||||||
Runs rsync as root, for the given host and file paths.
|
Runs rsync as root, for the given host and file paths.
|
||||||
|
|
||||||
|
:param files: If set, this indicates that each of the ``paths``
|
||||||
|
are actual files, as opposed to directories.
|
||||||
|
|
||||||
|
:param target: If set, this will be used instead of the given
|
||||||
|
path, for destination path. This only works correctly if
|
||||||
|
``paths`` contains only one path.
|
||||||
"""
|
"""
|
||||||
for path in paths:
|
for path in paths:
|
||||||
assert path.startswith('/')
|
assert path.startswith('/')
|
||||||
path = path.rstrip('/')
|
path = path.rstrip('/')
|
||||||
# escape path for rsync
|
# escape path for rsync
|
||||||
path = path.replace(' ', r'\\\ ').replace("'", r"\\\'")
|
path = path.replace(' ', r'\\\ ').replace("'", r"\\\'")
|
||||||
agent_sudo(c, 'rsync -aP --del root@{0}:{1}/ {1}'.format(host, path))
|
suffix = '' if files else '/'
|
||||||
|
agent_sudo(c, f'rsync -aP --del root@{host}:{path}{suffix} {target or path}')
|
||||||
|
|
Loading…
Reference in a new issue