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.

[!CAUTION] This tool is tested for the authors workflow and has worked flawlessly for the past several years. However, some caution is advised as this tool deals with synchronizing files across devices. Please keep backups.

[!NOTE] Feel free to request features or open bug tickets.

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

Author's use case

  • Have a root directory filled with subdirectories for different simulations
  • Need to run simulations distributed across different machines
  • With the configs set up locally,
    • tsync push server-1 -f dir01, tsync push server-2 -f dir02, ...
    • or from dir01, tsync push server-1 -f .
  • Run simulations on servers. It is now possible to use tsync cmd ... for remote execution
  • Run post processing on servers. tsync cmd ...
  • Only pull post-processed data to verify, tsync pull server-1 -f dir01/post, ...

You may also set each simulation directory as a root with only one specific remote where it is to be executed.

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.0.tar.gz (34.7 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.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tsync-0.1.0.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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.0.tar.gz
Algorithm Hash digest
SHA256 988513068211fa48b49fe3e4c71adb022743bd5b1f10b25d757af8d6dc15d126
MD5 7730f5473a1ab5bdc60324626fa97285
BLAKE2b-256 dd32350eb1e532f12c00437f72d40f889d997c2a98cbbfc79aeb63702bceedfb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tsync-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 457e87db816be8f6db5eb125e7ab7c8d88696798879d48e371ceda60b8f48817
MD5 08812eb5b8dca16898149c78ee11e881
BLAKE2b-256 ff8b562baea81d31de8a44c064228dae8cf2cdca9ada074b5a7b140af2a78f32

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