Skip to main content

Fast file synchronization for remote development over SSH

Project description

syncmux

Fast file synchronization for remote development over SSH. syncmux is designed for developers working on remote servers who need low-latency file syncing with persistent connections and robust logging.

Features

  • 🚀 Lightning Fast: Uses SSH ControlMaster to maintain persistent connections, eliminating handshake overhead for every file.
  • 📦 Smart Batching: Automatically switches to batch mode when multiple files change at once (e.g., switching git branches).
  • 🔄 Auto-Reconnect: Automatically attempts to reconnect if the network drops or the SSH connection is severed.
  • 🎯 Git-Aware: Respects .gitignore and logs git diffs for changes.
  • 📝 Comprehensive Logging: Keeps detailed logs of what changed on both the local machine and the remote server.

Prerequisites

  • Passwordless SSH: You must have SSH key-based authentication set up for the remote host (e.g., via ssh-copy-id), allowing usage without entering a password.
  • rsync: Must be installed on both the local machine and the remote server.

Installation

pip install syncmux

Usage

Quick Start

Start watching a directory and syncing to a remote server:

syncmux --local-dir ~/myproject --remote-host dev-server --remote-dir /home/user/myproject

Initial Sync

If you want to ensure the remote directory is an exact mirror of your local directory before starting the watcher (useful for fresh starts), use the --initial-sync flag.

⚠️ WARNING: This will delete files on the remote directory that are not present locally.

syncmux --local-dir ~/myproject --remote-host dev-server --remote-dir /home/user/myproject --initial-sync

Command Line Reference

usage: syncmux [-h] [--version] --local-dir LOCAL_DIR --remote-host REMOTE_HOST
               --remote-dir REMOTE_DIR [--debounce DEBOUNCE]
               [--batch-threshold BATCH_THRESHOLD]
               [--keepalive-interval KEEPALIVE_INTERVAL]
               [--keepalive-count KEEPALIVE_COUNT]
               [--connection-check-interval CONNECTION_CHECK_INTERVAL]
               [--reconnect-attempts RECONNECT_ATTEMPTS]
               [--reconnect-delay RECONNECT_DELAY] [--initial-sync]

Required arguments:
  --local-dir DIR       Local directory to watch
  --remote-host HOST    Remote SSH host (as defined in ~/.ssh/config or user@host)
  --remote-dir DIR      Remote directory path

Sync behavior:
  --debounce SEC        Seconds to wait after last change before syncing (default: 2.0)
  --batch-threshold N   Number of files to trigger batch sync mode (default: 5)

Connection tuning:
  --keepalive-interval N  SSH keepalive interval in seconds (default: 15)
  --reconnect-attempts N  Number of reconnection attempts (default: 5)

How It Works

Persistent Connection

syncmux sets up a master SSH connection (ssh -M) with ControlPersist. All subsequent sync operations (rsync) reuse this socket. This drastically reduces latency, especially on high-latency networks (like VPNs), as it avoids the SSH handshake overhead for transfer.

Logging and Diffs

syncmux maintains logs on both ends so you always know what happened.

Local Log (.syncmux-log in your local dir): Records every file synced along with the local git diff at the time of sync. This allows you to audit exactly what code changes were pushed.

============================================================
Timestamp: 2024-03-20 10:30:01
Synced: src/main.py
Remote: dev-server:/app/src/main.py
----------------------------------------
Diff:
diff --git a/src/main.py b/src/main.py
index ...
...

Remote Log (.sync-log in your remote dir): Records incoming syncs. If the remote directory is a git repo, it also attempts to capture the diff of the applied changes relative to the remote HEAD.

Contributing

See CONTRIBUTING.md for details on how to contribute to syncmux.

License

MIT License - see LICENSE file

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

syncmux-0.1.1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

syncmux-0.1.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file syncmux-0.1.1.tar.gz.

File metadata

  • Download URL: syncmux-0.1.1.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for syncmux-0.1.1.tar.gz
Algorithm Hash digest
SHA256 dcb0886a96a963608607717134bb58bb3332d855a5f098e45c23933ce80b7ca2
MD5 9aee8cd9df6dbb44b11de17ec43d2777
BLAKE2b-256 ab5784a30146031ff5866f75b4b825f060075126ecbcfb989455a0c2b3952cfa

See more details on using hashes here.

File details

Details for the file syncmux-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: syncmux-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for syncmux-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ada851fc066f24be5554a546692fc564b2a161a2c5662c5d35ae5dd21841a273
MD5 df9181a5e052892505db2b1b2fbd1d7d
BLAKE2b-256 7c618d1d30c92fdc826792d6a648d542b2846e749bbd493378e23862a5ae8608

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