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]
tsynccan 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
- Create a
.tsync.yamlin 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
- Push to a remote:
cd /path/to/project/subdir
tsync push server
This syncs the current directory to user@hostname:/path/to/backup/subdir/.
- 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
- Searches upward for
.tsync.yamlto find the project root - Computes the relative path from root to current directory
- Constructs the remote path:
<remote_root>/<relative_path>/ - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
988513068211fa48b49fe3e4c71adb022743bd5b1f10b25d757af8d6dc15d126
|
|
| MD5 |
7730f5473a1ab5bdc60324626fa97285
|
|
| BLAKE2b-256 |
dd32350eb1e532f12c00437f72d40f889d997c2a98cbbfc79aeb63702bceedfb
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
457e87db816be8f6db5eb125e7ab7c8d88696798879d48e371ceda60b8f48817
|
|
| MD5 |
08812eb5b8dca16898149c78ee11e881
|
|
| BLAKE2b-256 |
ff8b562baea81d31de8a44c064228dae8cf2cdca9ada074b5a7b140af2a78f32
|