Skip to main content

rsync wrapper to sync files between local machine and remotes with push/pull workflow

Project description

tsync

An rsync wrapper for syncing entire or partial directory trees between machines with a simple push/pull workflow.

[!TIP] tsync can be invoked from any nested subdirectory to synchronize the entire tree. Just define your remotes in .tsync.yaml at the root, then tsync push server from anywhere in the tree.

Use cases

  • Sync source code when developing and testing distributed applications.
    • git commit/push/pull loop works, but is not a good fit when developing.
  • Sync code to servers that have restrictions on storing private keys (can't pull).
  • Push data+configs, process on another machine, pull only relevant results.
  • Data clone, or a crude backup.

Features

  • Push/Pull workflow: Sync files to multiple remotes or pull from a single source
  • Config-based remotes: Define remotes once in .tsync.yaml, use by name
  • Directory structure preservation: Maintains relative paths from the config root
  • Flexible excludes/includes: Configure patterns in YAML or override via CLI
  • Diff with remotes: Compare local and remote states before syncing
  • Remote command execution: Run commands on remotes in the corresponding directory

Installation

pip install tsync

Or with uv:

uv tool install tsync    # install globally as a CLI tool
uvx tsync                 # run without installing

Or install from source:

git clone https://github.com/jayghoshter/tsync.git
cd tsync
pip install -e .

Quick Start

  1. Create a .tsync.yaml in your project root:
remotes:
    server: user@hostname:/path/to/backup
    nas: nas:/volume1/projects  # if 'nas' is in ssh config
    local_backup: /mnt/backup/projects

excludes:
    - __pycache__
    - .git
    - "*.pyc"
    - node_modules

includes:
    - important.pyc  # override excludes for specific files
  1. Push to a remote:
cd /path/to/project/subdir
tsync push server

This syncs the current directory to user@hostname:/path/to/backup/subdir/.

  1. Pull from a remote:
tsync pull server

Usage

Push

Push current directory to one or more remotes:

tsync push server              # push to 'server'
tsync push server nas          # push to multiple remotes
tsync push all                 # push to all configured remotes
tsync push server -f file.txt  # push specific files only

Pull

Pull from a remote to current directory:

tsync pull server
tsync pull server -f file.txt  # pull specific files only

Diff

Compare local and remote states:

tsync diff server           # quick rsync-based diff
tsync diff server --copy    # detailed diff with file contents

Remote Commands

Run commands on remotes in the corresponding directory:

tsync cmd --target server -- ls -la
tsync cmd --target server -- git status

Edit Config

Open the nearest .tsync.yaml in your editor:

tsync edit

Options

Option Description
-y, --no-confirm Don't prompt before syncing
-d, --dry-run Show what would be synced without doing it
-m, --mkdir Create remote directories before syncing
--delete Delete extraneous files on receiver
--delete-excluded Also delete excluded files on receiver
-ne, --no-excludes Ignore all exclude patterns
-e, --excludes Additional exclude patterns
-i, --includes Additional include patterns
-f, --files Specific files/directories to sync

Additional rsync options can be passed directly:

tsync push server -- --compress-level=9

Configuration

The .tsync.yaml file is searched upward from the current directory. The directory containing the config file is considered the "root" - all relative paths are computed from there.

remotes:
    # SSH remotes (rsync over SSH)
    server: user@host:/path/to/root
    shortname: hostname:/path/to/root  # uses ssh config

    # Local paths
    backup: /mnt/external/backup

excludes:
    - __pycache__
    - "*.pyc"
    - .git
    - .env
    - node_modules

includes:
    - .env.example  # include despite .env exclude pattern

How It Works

  1. Searches upward for .tsync.yaml to find the project root
  2. Computes the relative path from root to current directory
  3. Constructs the remote path: <remote_root>/<relative_path>/
  4. Runs rsync with the configured options

This means if you're in /home/user/projects/myapp/src/ and the .tsync.yaml is in /home/user/projects/myapp/, syncing to server: host:/backup will target host:/backup/src/.

Requirements

  • Python 3.10+
  • rsync (installed on both local and remote machines)
  • SSH access to remote machines (for SSH remotes)

License

MIT

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

tsync-0.1.1.tar.gz (34.6 kB view details)

Uploaded Source

Built Distribution

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

tsync-0.1.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tsync-0.1.1.tar.gz
  • Upload date:
  • Size: 34.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tsync-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c135da74d10443dee2fc56851177f3666966081dc0d9fdd0389a6bd97c7f8094
MD5 1becd1dc7be5dc43afbea7640658ccfc
BLAKE2b-256 f253dc9687a7b726e838b878d35b2782eb826529fc91224da4f5f5f177499259

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tsync-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tsync-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8633a7ab564b9aa4a25d74aad071be3e06dea598b905ab9dabec0386b5220ce3
MD5 1e9d5e53227a39d615a26efb3ee2514a
BLAKE2b-256 540754944cf20bc85449ae7ca1dadd171bea5179e2d1ad567e8f9e53b3d2c31c

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