-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add from_local option to transfers.rsync #29
base: master
Are you sure you want to change the base?
Conversation
'from_local' option indicates if the copy should be done from remote to local, the default is from local to remote.
The 'from_local' option had the opposite behavior to what it is supposed to do.
Could this be merged in? I could really use this as well. |
yeah, please merge 😄 |
Another vote for merge please, this feature is essential |
#38 Ops, I just found this PR. I issued another one for the same feature. |
@MacHu-GWU I made this back on 2018, the project is clearly and sadly inactive :( |
@ferares Is the author still active on GitHub? It is always good to have group of people maintaining open source project. |
Yeah he is @bitprophet |
If someone is interested, here a working snippet for rsync over Fabric's method Simply add this to your own inherited from Connection class def rsync(self, source, target, exclude=(), rsync_opts="", ssh_opts="",
delete=False, strict_host_keys=True, upload=True):
if isinstance(exclude, string_types):
exclude = [exclude]
# Double-backslash-escape
replace_bs = lambda s: str(s).replace('"', '\\\\"')
exclusions = " ".join((f'--exclude "{replace_bs(s)}"' for s in exclude))
# Honor SSH key(s)
keys = self.connect_kwargs.get("key_filename", [])
if isinstance(keys, string_types):
keys = [keys]
key_string = "-i " + " -i ".join(keys) if keys else ""
port_string = f"-p {self.port}"
# Workaround for our old keys:
ssh_opts += '-o "PubkeyAcceptedKeyTypes +ssh-dss"'
# Strict host key checking
disable_keys = "-o StrictHostKeyChecking=no"
if not strict_host_keys and disable_keys not in ssh_opts:
ssh_opts += " {}".format(disable_keys)
# Remote shell (SSH) options
rsh_parts = [key_string, port_string, ssh_opts]
rsh_string = "--rsh='ssh {}'".format(" ".join(rsh_parts)) if any(rsh_parts) else ""
# Set up options part of string
options = f'{"--delete" if delete else ""}{exclusions} -pthrvz {rsync_opts} {rsh_string}'
remote_prefix = f"{self.user}@{self.host}"
if self.host.count(":") > 1:
remote_prefix = f"[{remote_prefix}]"
upload_direction = f"{source} {remote_prefix}:{target}" if upload else f"{remote_prefix}:{source} {target}"
print(f'rsync {options} {upload_direction}')
return self.local(f"rsync {options} {upload_direction}") |
'from_local' option indicates if the copy should be done from remote to local, the default is from local to remote.
closes #26