Skip to main content

syncengine backend for file synchronization

Project description

PyPI - Version PyPI - Python Version PyPI - Downloads codecov

syncengine

A flexible, bidirectional file synchronization engine for Python that supports multiple sync modes and conflict resolution strategies.

What is syncengine?

syncengine is a powerful file synchronization library that enables you to keep files synchronized between two locations (source and destination). Unlike simple copy operations, syncengine intelligently tracks file state, detects changes, handles conflicts, and provides multiple synchronization modes to fit different use cases.

Why is syncengine useful?

Real-world Use Cases

  1. Cloud Storage Synchronization

    • Sync local files with cloud storage (Dropbox, Google Drive, S3, etc.)
    • Implement custom cloud backup solutions
    • Build your own sync client with fine-grained control
  2. Backup Management

    • Create one-way backup systems (never delete backed-up files)
    • Implement versioned backup strategies
    • Maintain disaster recovery copies
  3. Development Workflows

    • Sync code between local development and remote servers
    • Mirror files to multiple deployment targets
    • Keep test environments synchronized with production data
  4. Content Distribution

    • Distribute files from a master source to multiple destinations
    • Keep documentation or assets synchronized across systems
    • Manage multi-site content updates

Key Features

  • Multiple Sync Modes: Choose the behavior that fits your needs

    • TWO_WAY: Bidirectional sync with conflict detection
    • SOURCE_TO_DESTINATION: Mirror source to destination (typical one-way sync)
    • SOURCE_BACKUP: Protect source from deletions (upload-only backup)
    • DESTINATION_TO_SOURCE: Mirror destination to source (cloud download)
    • DESTINATION_BACKUP: Protect local backup from remote changes
  • Intelligent Change Detection

    • Tracks file modifications via timestamps and sizes
    • Detects renames and moves
    • Identifies conflicts when both sides change
  • Flexible Conflict Resolution

    • Newest file wins
    • Source always wins
    • Destination always wins
    • Manual conflict handling
  • State Management

    • Persistent state tracking across sync sessions
    • Resume interrupted syncs
    • Detect changes since last sync
  • Pattern-based Filtering

    • Gitignore-style ignore patterns
    • Include/exclude specific files or directories
    • Control what gets synchronized
  • Progress Tracking ✨ NEW

    • Real-time file-level progress events
    • Byte-level transfer progress with speed and ETA
    • Per-folder statistics
    • Thread-safe for parallel operations
    • Rich progress bar support
  • Protocol Agnostic

    • Works with any storage backend (local, S3, FTP, custom protocols)
    • Pluggable storage interface
    • Easy to extend for new storage types

Quick Example

from syncengine import SyncEngine, SyncMode, LocalStorageClient, SyncPair

# Create storage clients
source = LocalStorageClient("/path/to/source")
destination = LocalStorageClient("/path/to/destination")

# Create sync engine
engine = SyncEngine(mode=SyncMode.TWO_WAY)

# Create sync pair
pair = SyncPair(
    source_root="/path/to/source",
    destination_root="/path/to/destination",
    source_client=source,
    destination_client=destination
)

# Perform sync
stats = engine.sync_pair(pair)
print(f"Uploaded: {stats['uploads']}, Downloaded: {stats['downloads']}")

When to Use Each Sync Mode

Mode Use Case Source Changes Destination Changes Deletions
TWO_WAY Keep both sides in sync Upload Download Propagated both ways
SOURCE_TO_DESTINATION Mirror source to destination Upload Ignored (deleted) Propagated to destination
SOURCE_BACKUP Backup source, never delete Upload Download Never delete source
DESTINATION_TO_SOURCE Mirror destination to source Ignored (deleted) Download Propagated to source
DESTINATION_BACKUP Backup from destination Ignored Download Never delete local backup

Installation

pip install syncengine

Or for development:

git clone https://github.com/holgern/syncengine
cd syncengine
pip install -e .

Benchmarks

The project includes comprehensive benchmarks that test all sync modes with various scenarios. See benchmarks/README.md for details.

Run benchmarks:

python benchmarks/run_benchmarks.py

Documentation

For detailed API documentation, see the individual module docstrings:

  • syncengine/engine.py - Main sync engine
  • syncengine/modes.py - Sync mode definitions
  • syncengine/progress.py - Progress tracking API ✨ NEW
  • syncengine/comparator.py - Change detection logic
  • syncengine/protocols.py - Storage protocol interfaces
  • syncengine/config.py - Configuration options

Contributing

Contributions are welcome! Please ensure:

  • Tests pass: pytest tests/
  • Benchmarks pass: python benchmarks/run_benchmarks.py
  • Code follows project style

License

See LICENSE file for details.

Project details


Download files

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

Source Distribution

syncengine-0.2.0.tar.gz (152.1 kB view details)

Uploaded Source

Built Distribution

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

syncengine-0.2.0-py3-none-any.whl (69.4 kB view details)

Uploaded Python 3

File details

Details for the file syncengine-0.2.0.tar.gz.

File metadata

  • Download URL: syncengine-0.2.0.tar.gz
  • Upload date:
  • Size: 152.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for syncengine-0.2.0.tar.gz
Algorithm Hash digest
SHA256 93decccc9baf21da6ad49a910d4b7f19ccb2b2a2c574582c887710bd3306d793
MD5 6cf30ca0469ed1ae1ab3182a4c5492fa
BLAKE2b-256 2ef817baa7d88fa957e438b2006acca796940ec66828cd291fc83e25492ff0af

See more details on using hashes here.

File details

Details for the file syncengine-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: syncengine-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 69.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for syncengine-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1fff2ccf5d8e2318dd7b0ace0b64c2c68904a694a10df53ee849018c133e16b5
MD5 01a58f361114b786c4251fed2f722375
BLAKE2b-256 d00160ab56717955506064f8f5153960169865560e93366de4b084a6cfc1c6c2

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