user996554
user996554

Reputation: 105

How to resume file transferring with paramiko

I'm working on a Python project that is required some file transferring. One side of the connection is highly available ( REHL 6 ) and always online. But the other side is going on and off ( Windows 7 ) and the connection period is not guaranteed. The files are transporting on both directions and sizes are between 10MB to 2GB.

Is it possible to resume the file transferring with paramiko instead of transferring the entire file from the beginning.

I would like to use rSync but one side is windows and I would like to avoid cwRsync and DeltaCopy

Upvotes: 3

Views: 2341

Answers (2)

cowlinator
cowlinator

Reputation: 8784

paramiko.sftp_client.SFTPClient contains an open function, which functions exactly like python's built-in open function.
You can use this to open both a local and remote file, and manually transfer data from one to the other, all the while recording how much data has been transferred. When the connection is interrupted, you should be able to pick up right where you left off (assuming that neither file has been changed by a 3rd party) by using the seek method. Keep in mind that a naive implementation of this is likely to be slower than paramiko's get and put functions.

Upvotes: 2

MiiinimalLogic
MiiinimalLogic

Reputation: 818

Paramiko doesn't offer an out of the box 'resume' function however, Syncrify, DeltaCopy's big successor has a retry built in and if the backup goes down the server waits up to six hours for a reconnect. Pretty trusty, easy to use and data diff by default.

Upvotes: 2

Related Questions