Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Synchronise files between a local cache and an SFTP server

Project Description

Synchronise files piecemeal back and forth between a local cache and a remote SFTP server.

Use case

You have a client that sometimes needs to syncronise files to and from an SFTP server.

  • open() a file whether it’s remote or local. * If the file is available locally, use the local copy. * If the local file doesn’t exist, download it and then use the local copy.
  • add() files to an upload package, then push() to upload all locally queued files.

This model is simplistic, and will clobber any changes at the other end if a file with the same name exists. If you want to avoid that, you may be better off using Git or the like.

How to use:

import sftpsyncer
from sftpsyncer import syncagent

sagent = syncagent(hostname="", host_port="1222",
                username="theuser", key_path="/home/theuser/.sagenth/key",
                local_root="/tmp/cache", remote_root="/upload_target")

# upload local files


sagent.push()  # upload whether or not remote files exist

# auto-get remote files, reading from cache when available

fh1 ="myfile.txt")  # file is already local, return local fh
fh2 ="remote.txt")  # file is not local, transfer to local cache, return local fh

# exceptions

    fh3 ="not_anywhere.txt")
except sftpsyncer.exceptions.FileNotFound as e:
    print "File does not exist on local or remote"

    fh5 ="ssh_server_unavailable.txt")
except sftpsyncer.exceptions.ConnectionError as e:
    print "Remote SFTP service appears to be unavailable"

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(11.7 kB) Copy SHA256 Hash SHA256
Source None Aug 29, 2016

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting