Directory synchronization tool yd
Build and execute rsync commands from TOML configuration files.
(Un)Install
To install, run
uv tool install yd-cli
Then run
yd --install-completion
to install auto-completion in your shell.
In bash, the completion code is stored in ~/.bash_completions/yd.sh and that file is sourced from ~/.bashrc.
Remove both and call uv tool uninstall yd-cli to remove this tool.
The below mentioned configuration files need to be removed separately.
Create a config
Create a new configuration called photos with:
yd edit --new photos
This command
- creates
~/.config/yd/photos.toml(or under$XDG_CONFIG_HOME/ydif set; relative paths are resolved from your home directory), and - opens it with the executable selected via
EDITOR, ornvimwhenEDITORis unset.
Reopen an existing configuration with:
yd edit photos
Configuration format
Example
# Phone backup
src_home = "/home/alice"
target_home = "/mnt/backup"
backup = "deleted/%Y-%m-%d"
exclude = [".venv/", "__pycache__/"]
[[commands]]
src = "Documents"
exclude = ["*.log"]
[[commands]]
src = "Pictures"
target = "pics-%Y-%m-%d"
delete_extra = false
Leading comment lines directly at the top of the file are treated as the configuration description and are shown by yd ls.
Top-level options
| Key | Meaning |
|---|---|
src_home |
Base directory for all src paths. Relative paths are resolved from your home directory. |
target_home |
Base directory for all target paths. Relative paths are resolved from your home directory. |
mtp_target |
Use in-place syncing for MTP targets. |
backup |
Backup directory for replaced or deleted files. Relative paths are resolved from target_home. strftime placeholders are supported. |
exclude |
Exclude patterns applied to every command. |
mtp_target matters because rsync normally copies to a temporary file and renames it afterward, but that is not possible when syncing via MTP.
Command options
| Key | Meaning |
|---|---|
src |
Relative source directory below src_home. |
target |
Relative target directory below target_home; defaults to src. strftime placeholders (%Y, %m, and %d only!) are supported. A newly created dated target is removed if it contains only directories after synchronization. |
delete_extra |
Delete files in the target that do not exist in the source. Defaults to true. |
exclude |
Extra exclude patterns for this command only. |
Notes
srcandtargetmust stay withinsrc_homeandtarget_homeafter path resolution.- Literal targets are retained when they contain only empty directories. Dated targets serve as snapshots: if a dated target did not exist before synchronization and contains neither files nor symlinks afterward,
ydremoves its empty directory tree. src_homeortarget_homemay be omitted from the configuration, but every missing value must then be supplied when running (via CLI parameters).- Exactly one of
--src-home -and--target-home -may read from standard input in a single run. - If
backupis omitted,ydcreates a timestamped backup directory automatically unless--no-backupis specified. - If a configured source directory exists but is empty,
ydreports that no synchronization was performed for that command. E.g., forgetting to mount an external drive does not delete all corresponding copies on hard-drive. - If
strftimeplaceholders are included in thetarget, then thetarget_homeis scanned for matching directories (possibly) created by this rule before today. The 20 most recent matches are included as additional comparison destinations in the synchronization: if a file insrcis included in one of those reference directories, then it will not be copied totarget.
Run a config
Run a saved configuration by name:
yd run photos
Options
| Option | Meaning |
|---|---|
--dry-run |
Show what would happen without changing files. |
--no-backup |
Disable backup handling for this run. |
--keep-newer |
Skip updates when the target file is newer. |
--rename-speedup |
Enable rsync options tuned for rename-heavy targets. This may require more disk space on the target. |
--src-home PATH |
Override src_home from the config. Use - to read the value from standard input. |
--target-home PATH |
Override target_home from the config. Use - to read the value from standard input. |
Logging
Set YD_LOGLEVEL to a numeric Python logging level, such as 10 for debug, 20 for info, or 40 for errors.
When set, yd appends JSON Lines records to .yd.jsonl in the current working directory.
Records contain time, level, logger, and message fields, plus exception type, message, and traceback when applicable.
Logging is effectively disabled by default. Enable it when diagnosing a failed or interrupted run.
List configs
List available configurations with:
yd ls
This shows the configuration name together with the optional leading-comment description.
Why yd?
- Has one character from
synchronizeand one fromdirectory. - Easy to type with both QWERTZ and QWERTY keyboards.
- Name was still available on PyPI.
Metadata
Release files for yd-cli 0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| yd_cli-0.12.tar.gz | 25.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yd_cli-0.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.9 kB
Release files / yd_cli-0.12.tar.gz
| Download URL | yd_cli-0.12.tar.gz |
|---|---|
| Size | 25.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4edaffd6b36b569689d4951190edee65479a37fa042c74357d264a2a19a0adef
|
|
BLAKE2b-256 checksum How to use checksums |
3d62db6aece8e5d4330e38df0757e2a19934870345c041dc358c536f954f0209
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / yd_cli-0.12-py3-none-any.whl
| Download URL | yd_cli-0.12-py3-none-any.whl |
|---|---|
| Size | 29.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae6e88f0fe60ad865a6ee94aab2664d021f9ed252af7323eb555a0c61d9c3eca
|
|
BLAKE2b-256 checksum How to use checksums |
d6aabf3333aaf232787908189f756e5b1005648bcf76ea6043aa07f6e96b2806
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|