x-rsync

A tiny, cross-platform rsync alternative to sync changed files using SFTP and SHA-256 diffing.


The Idea

x-rsync is a lightweight, cross-platform file synchronization tool built for Node and TypeScript. It syncs only changed files to remote servers over SSH—no rsync or native binaries required. Whether you're on Windows, macOS, or Linux, x-rsync provides intelligent file diffing using SHA-256 hashing and SFTP to keep your deployments fast and efficient.


What It Offers

Smart Sync Commands

Three simple commands to manage your deployments:

  • sync - One-command solution that pulls remote state and pushes local changes
  • pull - Download remote file list and create/update manifest
  • push - Upload only changed files based on manifest

Intelligent Diffing

Efficient change detection with:

  • SHA-256 hash comparison for accurate file change detection
  • Fast mode option (size + mtime comparison) for large codebases
  • Dry run mode to preview changes before execution
  • Auto-pull when no manifest exists

Flexible Configuration

Multiple ways to configure:

  • Config file support (xsync.config.js or xsync.config.ts)
  • Environment variables and .env file support
  • CLI flags for on-the-fly adjustments
  • Glob pattern support for exclude/include rules

Cross-Platform SSH Support

Works everywhere with:

  • OpenSSH private key authentication
  • Password authentication
  • Custom port configuration
  • Native Windows support (including key conversion from .ppk)

Key Features

  • Optional remote deletion: Use --delete to remove remote files not present locally
  • Pattern matching: Exclude/include files using glob patterns
  • Bundled CLI: Single JavaScript file distribution via esbuild
  • TypeScript support: First-class TypeScript configuration and development experience
  • Minimal dependencies: Lightweight with only essential dependencies

Why Choose x-rsync

  • Pure JavaScript/TypeScript solution—no native binaries or platform-specific tools
  • Works seamlessly on Windows without WSL or Cygwin
  • Simple three-command API that handles complex sync logic
  • Smart auto-detection prevents sync mistakes
  • Perfect for CI/CD pipelines and automated deployments

FAQs

  • Why not use rsync? rsync isn't natively available on Windows and requires native binaries. x-rsync works everywhere Node runs.
  • How does it compare to rsync? Similar functionality but optimized for Node workflows. Uses SFTP instead of rsync protocol.
  • Is it production-ready? Yes—designed for real deployments with dry-run, exclude patterns, and manifest-based diffing.
  • What about large files? Fast mode (--fast) skips hashing and uses size/mtime comparison for better performance.
  • How do I get started? Install via npm, create a config file, and run x-rsync sync ./dist

Tech

Built with Node.js, TypeScript, ssh2-sftp-client for SFTP, minimatch for glob patterns, and bundled with esbuild for single-file distribution.