jererc / sftpsync-py Goto Github PK
View Code? Open in Web Editor NEWSFTP sync library
SFTP sync library
Sync files and directories over SSH. Update destination files according to the source size and modified time. Remove destination files and directories if not present at source or excluded (include/exclude parameters). Example: # We synchronize a stock Android phone sdcard mountpoint to our home (assuming a SSH server is running on the device) from sftpsync import Sftp sftp = Sftp('192.168.1.149', 'root', 'password', port=2222) src = '/mnt/sdcard' dst = '/home/user/phone-backup/' # We don't want to backup everything exclude = [r'^Music/', r'^Video/'] sftp.sync(src, dst, download=True, exclude=exclude, delete=True) # We sync a local directory to the phone src = '/home/user/data/code/sftpsync-py' dst = '/mnt/sdcard/data/' sftp.sync(src, dst, download=False, delete=True)
I add a finally function below to colose sftp connection, not sure if it still working
except (paramiko.BadHostKeyException, paramiko.AuthenticationException) as e:
raise AuthenticationError(str(e))
except socket.timeout as e:
raise TimeoutError(str(e))
except Exception as e:
if i == max_attempts - 1:
raise SshError(str(e))
finally:
if self.client:
self.client.close()
I am trying to use it in order to copy from a folder in an sftp into a local folder of my pc:
folder:
one_folder:
1 file.txt
other_file.txt
other_folder:
once_more_file.txt
The result in dest is that I have only "one_folder" and "other_folder" but both empty.
sftp.sync(src, dst, download=True, delete=True)
been src a folder in the ftp server, and dst a folder in my local machine.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.