Skip to main content

TinySync is a two-path (bi-direction) synchronization algorithm implemented in pure Python that can synchronize files between any two kinds of backends.

Project description

TinySync README

TinySync

TinySync is a two-way synchronization algorithm implemented in pure Python, enabling file synchronization between any two types of backends. A backend can be a local file system, a WebDAV server, or any other user-defined storage medium. The synchronization algorithm is adapted from the syncrclone project. In principle, this project is compatible with all operating systems, though most testing has been performed on Ubuntu.

Installation

pip install tinysync

Examples

Synchronization between Local Directory and WebDAV

This example illustrates how to synchronize a remote WebDAV storage with a local directory.

import tinysync


# set a local dir
backendA = tinysync.backend.LocalFS(dirPath="/home/XXX/Desktop/p1")


# set another backend on webdav
options = {'webdav_hostname': "...",'webdav_login': "...",'webdav_password':"..."}
backendB = tinysync.backend._WebDAV(dirPath='p2',options=options)


# run sync method
tinysync.synchronization(backendA,backendB)

Synchronization between Local Directory and SSH Server

This example demonstrates file synchronization between a local directory and a remote directory on an SSH server.

import tinysync

# set one backend
config={"hostname":'...',"username":'...',"password":'...',}
remote_path = '/home/user/path'  # the remote directory to list
backendA = tinysync.backend.NixSSH(dirPath=remote_path,paramikoConfig=config)


# set another backend 
options = {'webdav_hostname':"...",'webdav_login':"...",'webdav_password':"...",}
backendB = tinysync.backend._WebDAV(dirPath='p2',options=options)


# run sync method
tinysync.synchronization(backendA,backendB)

Synchronization between Any Two Backends

This feature supports synchronization between any two remote storage locations. The machine executing this code acts as a "working machine" and does not retain any information about the two backends. All state data is stored on the backend side.

Other Backends

Rclone example:

rclone = tinysync.backend.Rclone(dirPath="disk:path/to/here")

User-defined Backend

For general use cases, you can define a custom backend interface by creating a new backend class. Detailed methods and implementation examples are available in tinysync.backend.abc.

from tinysync.backend.abc import Backend

class YourBackend(Backend):
    
    def __init__(...):
        ...


    def listPath(self,...):
        ...

    ...

Notice

Do NOT delete the workdir (default: .tinysync) from one backend while retaining it on the other. This will result in the deletion of all files in the backend where the workdir was retained. This behavior, inherited from syncrclone, is not ideal, but it will not be modified. To perform a full resynchronization, it is safe to delete the workdir from both backends.

Currently Implemented Backends

  • tinysync.backend.LocalFS

  • tinysync.backend._WebDAV

  • tinysync.backend.NixSSH

  • tinysync.backend.FTP (Example: FTP(dirPath="", host='127.0.0.1', username='123', password='456'))

  • tinysync.backend.Rclone (consider using syncrclone)

More backends coming soon...

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tinysync-0.0.22-py3-none-any.whl (55.0 kB view details)

Uploaded Python 3

File details

Details for the file tinysync-0.0.22-py3-none-any.whl.

File metadata

  • Download URL: tinysync-0.0.22-py3-none-any.whl
  • Upload date:
  • Size: 55.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for tinysync-0.0.22-py3-none-any.whl
Algorithm Hash digest
SHA256 30bb1f2e3257b012ac65c12af48ff06183ed7fae9c376df33aabd4167809cc76
MD5 30e4fee3174e3a7e6242191e329d4474
BLAKE2b-256 80468c20eb2b82dd635856c53f4181685d43482d54ff91766e2447ff86c29820

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page