Uh oh!
There was an error while loading. Please reload this page.
Add from_local option to transfers.rsync - #29
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.
abingham
commented
Feb 11, 2019
Could this be merged in? I could really use this as well. |
gerazov
commented
Apr 20, 2019
yeah, please merge 😄 |
WildWeazel
commented
Dec 3, 2019
Another vote for merge please, this feature is essential |
MacHu-GWU
commented
Jan 23, 2020
#38 Ops, I just found this PR. I issued another one for the same feature. |
ferares
commented
Jan 24, 2020
@MacHu-GWU I made this back on 2018, the project is clearly and sadly inactive :( |
MacHu-GWU
commented
Jan 24, 2020
@ferares Is the author still active on GitHub? It is always good to have group of people maintaining open source project. |
ferares
commented
Jan 24, 2020
Yeah he is @bitprophet |
trammik
commented
Sep 13, 2021
If someone is interested, here a working snippet for rsync over Fabric's method Simply add this to your own inherited from Connection class defrsync(self, source, target, exclude=(), rsync_opts="", ssh_opts="",
delete=False, strict_host_keys=True, upload=True):
ifisinstance(exclude, string_types):
exclude= [exclude]
# Double-backslash-escapereplace_bs=lambdas: str(s).replace('"', '\\\\"')
exclusions=" ".join((f'--exclude "{replace_bs(s)}"'forsinexclude))
# Honor SSH key(s)keys=self.connect_kwargs.get("key_filename", [])
ifisinstance(keys, string_types):
keys= [keys]
key_string="-i "+" -i ".join(keys) ifkeyselse""port_string=f"-p {self.port}"# Workaround for our old keys:ssh_opts+='-o "PubkeyAcceptedKeyTypes +ssh-dss"'# Strict host key checkingdisable_keys="-o StrictHostKeyChecking=no"ifnotstrict_host_keysanddisable_keysnotinssh_opts:
ssh_opts+=" {}".format(disable_keys)
# Remote shell (SSH) optionsrsh_parts= [key_string, port_string, ssh_opts]
rsh_string="--rsh='ssh {}'".format(" ".join(rsh_parts)) ifany(rsh_parts) else""# Set up options part of stringoptions=f'{"--delete"ifdeleteelse""}{exclusions} -pthrvz {rsync_opts}{rsh_string}'remote_prefix=f"{self.user}@{self.host}"ifself.host.count(":") >1:
remote_prefix=f"[{remote_prefix}]"upload_direction=f"{source}{remote_prefix}:{target}"ifuploadelsef"{remote_prefix}:{source}{target}"print(f'rsync {options}{upload_direction}')
returnself.local(f"rsync {options}{upload_direction}") |
lvotapka
commented
Aug 25, 2025
This was helpful, thank you. |
'from_local' option indicates if the copy should be done from remote to local, the default is from local to remote.
closes#26