Skip to main content

Unit Tests Style Checks

Tree synchronization utility

This utility allows configuring regularly repeated rsync commands and sharing of configuration flags per server. Configured sync targets can be called with treesync pull and treesync push commands to avoid mistakes in repeated long and complex rsync arguments.

Example usage

Following example commands show how to use the tool for listing and syncing multiple targets.

These example commands match the example configuration shown below.

# List all targets
> treesync list
laptop:music
nas:documents
nas:music

# Lists targets where host or target name starts with letter s or m
> treesync list s* m*
laptop:music
nas:music

# Pull documents files from nas server
> treesync pull nas-server:documents

# Push music to bot nas-server and laptop
> treesync push music

# Push all files to nas-server
> treesync push nas-server

Installing

Install latest version from pypi:

pip install treesync

Configuration file

Configuration file for treesync tool is ~/.config/treesync.yml. The file suppports defining sync targets in two formats. Both formats can be mixed in same configuration file.

If same target name is defined in both formats, the sources and hosts declaration is used.

Sources and hosts format

The sources and hosts format contains two sections:

  • sources list of dictionaries with name and path elements and with optional excludes_file option
  • hosts list of dictionaries with at least name and targets options and with optional iconv, rsync_path and flags options

This format is suitable to use when same source is pushed to multiple target servers: the format defines source path and excludes file in one place and avoids copypaste errors.

Example configuration with all supported flags:

hosts:
  # macOS laptop with 'rsync 3' from homebrew
  - name: laptop
    # Defines the rsync command path on remote host (from macOS homebrew)
    rsync_path: /usr/local/bin/rsync
    targets:
      # Listed as laptop:music
      - source: music
        # The laptop is also a Mac, so no iconv is needed
        destination: mylaptop:/Users/myname/Music
  # Demo host with Linux or FreeBSD, requiring the 'iconv' config
  - name: nas
    # This is rsync flag to push from macOS to Linux/BSD
    iconv: UTF-8-MAC,UTF-8
    # Remove server will have different username
    flags:
      - --usermap=localuser:nasuser
      - --groupmap=localgroup:nasgroup
    targets:
      # The source field refers to 'sources' section name field
      # Listed as nas:documents
      - source: documents
        # Destination is full rsync command remote path without any special quoting
        destination: nas-server:/backups/My Documents
      # Listed as nas:music
      - source: music
        destination: nas-server:/shared/Music
sources:
  - name: documents
    path: /Users/myname/Documents
    excludes_file: /Users/myname/Documents/.rsync_exclude
  - name: music
    path: /Users/myname/Music
    excludes_file: /Users/myname/.music-excluded

Targets format

The targets format defines sync targets with targets with a single configuration section and server specific settings with servers section. In this format, the excludes_file must be repeated for each 'source' and source paths are repeated if pushed to multiple servers.

This format is suitable for cases where the same source is not pushed to multiple targets.

Server name to get server settings from serverssection is recognized from the destination field path by separating the path from first : letter.

servers:
  laptop:
    # Defines the rsync command path on remote host
    rsync_path: /usr/local/bin/rsync
  nas-server:
    # This is rsync flag to push from macOS to Linux/BSD
    iconv: UTF-8-MAC,UTF-8
    # Remove server will have different username
    flags:
      - --usermap=localuser:remoteuser
      - --groupmap=localgroup:users
targets:
  nas:documents:
    source: /Users/localuser/Documents
    destination: nas-server:/shared/Music
    excludes_file: /home/localuser/Documents/.rsync_exclude
  nas:music:
    source: /Users/localuser/Music
    destination: nas-server:/shared/Music
    excludes_file: /Users/myname/.music-excluded
  laptop:music:
    source: /Users/localuser/Music
    destination: nas-server:/shared/Music
    excludes_file: /Users/myname/.music-excluded

Examples of valid configuration files can be also seen in unit test data:

Metadata

Release files for treesync 1.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for treesync 1.5.1
File Size Uploaded Provenance
treesync-1.5.1.tar.gz 13.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for treesync 1.5.1
File Interpreter ABI Platform
treesync-1.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 33.9 kB

Release files / treesync-1.5.1.tar.gz

Download URL treesync-1.5.1.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3abcbc4a690105a9bdf636fc9977284399d3f1f9b84b576f1b76a4a5a65322f3
BLAKE2b-256 checksum
How to use checksums
5ae928ab15decdfd37014dbfe2677d3b094f0497255e1ba1d9e582f2dbc1bac4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0

Release files / treesync-1.5.1-py3-none-any.whl

Download URL treesync-1.5.1-py3-none-any.whl
Size 20.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31239e7a6afcb4f8ebb4d1aed40cd90efe358770bb06501f22dd696d6509c140
BLAKE2b-256 checksum
How to use checksums
0663da810a31b93881601906500441b3ae2657a7ab21f768fdd35e4b5bc3ef4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0

Security for treesync 1.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page