Package: treesync
Tree synchronization utilityThis utility allows configuring regularly repeated rsync commands and sharing
of configuration flags per server. Configuredsync targetscan be called
withtreesync pullandtreesync pushcommands to avoid mistakes in repeated
long and complex rsync arguments.Example usageFollowing 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>treesynclist
laptop:music
nas:documents
nas:music# Lists targets where host or target name starts with letter s or m>treesynclists*m*
laptop:music
nas:music# Pull documents files from nas server>treesyncpullnas-server:documents# Push music to bot nas-server and laptop>treesyncpushmusic# Push all files to nas-server>treesyncpushnas-serverInstallingInstall latest version frompypi:pipinstalltreesyncConfiguration fileConfiguration 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, thesources and hostsdeclaration is used.Sources and hosts formatThesourcesandhostsformat contains two sections:sourceslist of dictionaries withnameandpathelements and with optionalexcludes_fileoptionhostslist of dictionaries with at leastnameandtargetsoptions and with optionaliconv,rsync_pathandflagsoptionsThis 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/rsynctargets:# Listed as laptop:music-source:music# The laptop is also a Mac, so no iconv is neededdestination: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/BSDiconv:UTF-8-MAC,UTF-8# Remove server will have different usernameflags:---usermap=localuser:nasuser---groupmap=localgroup:nasgrouptargets:# 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 quotingdestination:nas-server:/backups/My Documents# Listed as nas:music-source:musicdestination:nas-server:/shared/Musicsources:-name:documentspath:/Users/myname/Documentsexcludes_file:/Users/myname/Documents/.rsync_exclude-name:musicpath:/Users/myname/Musicexcludes_file:/Users/myname/.music-excludedTargets formatThetargetsformat defines sync targets withtargetswith a single configuration section
and server specific settings withserverssection. 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 fromserverssection is recognized from thedestinationfield path by separating the path from first:letter.servers:laptop:# Defines the rsync command path on remote hostrsync_path:/usr/local/bin/rsyncnas-server:# This is rsync flag to push from macOS to Linux/BSDiconv:UTF-8-MAC,UTF-8# Remove server will have different usernameflags:---usermap=localuser:remoteuser---groupmap=localgroup:userstargets:nas:documents:source:/Users/localuser/Documentsdestination:nas-server:/shared/Musicexcludes_file:/home/localuser/Documents/.rsync_excludenas:music:source:/Users/localuser/Musicdestination:nas-server:/shared/Musicexcludes_file:/Users/myname/.music-excludedlaptop:music:source:/Users/localuser/Musicdestination:nas-server:/shared/Musicexcludes_file:/Users/myname/.music-excludedExamples of valid configuration files can be also seen in unit test data:sources and hosts configurationold format target list configuration