Skip to main content

The last dotfile syncer you'll ever need.

Project description

dotsync: fast-sync to all your hosts

dotsync is a blazing fast CLI for syncing dotfiles to all your remote machines — dotfiles everywhere, instantly.

dotsync logo

Features

dotsync demo

  • Concurrent smart sync to multiple hosts over SSH — talking 100s of files to 100s of hosts
  • Just-in-time SSH to bring your dotfiles with you wherever you SSH
  • Watch mode for instant sync on file changes — no more manual pushes/pulls
  • Flexible configuration with per-source and per-destination options
  • Templating support for dynamic per-destination contents via Jinja
  • Robust error handling with retries and logging, and never deletes files
  • Dry-run mode to preview sync actions without making changes

Installation

Homebrew

brew install hcgatewood/tap/dotsync

Pip

pip install dotsync_fast
# ...and install dependencies: rsync >= 3.2.3

Usage

Initialize your config

# Create sample config file in ~/.dotsync/<hostname>.dotsync.yaml
dotsync init

# Show the materialized config file
dotsync show

Quick sync

# Sync everything
dotsync

# Sync specific hosts
dotsync host1 host2

# Sync hosts by specific tags
dotsync @work @personal

Watch for changes and sync automatically

# Watch and sync everything
dotsync watch

# Watch and sync specific hosts/tags
dotsync watch host1 @work

SSH and bring your dotfiles with you

# Automatically sync dotfiles just-in-time on SSH
# With wildcard support, e.g. "*" for all hosts
dotsync ssh host1

With templating support for per-host customizations

# Create a templated version of your dotfile, with {{ var }} placeholders
vim ~/.zshrc.tpl.j2

# Edit your config file to define the desired vars per remote host/group
dotsync edit

# Sync/watch like normal, templated files will be rendered per remote host
dotsync sync

Configuration

The config is a YAML file located at ~/.dotsync/<hostname>.dotsync.yaml or ~/.dotsync/dotsync.yaml. The <hostname> is the current machine's hostname, allowing per-source-machine configurations.

groups:
  work:
    vars: { company: pinterest }
    paths:
      /local/src: /remote/dst

hosts:
  devapp:
    tags: [ work ]              # tags organize hosts + default group-level settings
    vars: { env: production }   # vars when templating *.tpl.j2 files
    paths:
      /local/src: /remote/dst   # *.tpl.j2 src files will be templated

Reference

Top-level

Usage: dotsync [OPTIONS] COMMAND [ARGS]...

  CLI for syncing dotfiles to remote hosts.

Options:
  -h, --help  Show this message and exit.

Commands:
  edit (e)   Edit dotfiles configuration file.
  init (i)   Initialize dotfiles configuration on the current machine.
  show (o)   Show dotfiles to be synced based on configuration.
  ssh (h)    SSH into a remote host configured in dotsync.
  sync (s)   Sync dotfiles to remote machines based on configuration.
  watch (w)  Watch dotfiles for changes and sync automatically.

Sync and watch

Usage: dotsync sync [OPTIONS] [REMOTES]...

  Sync dotfiles to remote machines based on configuration.

  REMOTES: optional list of remotes (either hostnames or @tags) to sync to; if not provided, syncs to all configured
  hosts.

Options:
  -c, --config FILE     Path to the dotsync configuration file. Defaults to searching in $DOTSYNC_CONFIG_DIR or
                        ~/.dotsync for <hostname>.dotsync.yaml then dotsync.yaml
  --src-concur INTEGER  Maximum concurrent source file syncs.  [default: 30]
  --force               Force overwrite of existing files on remote hosts.
  --dry, --dry-run      Only show what would be synced, without performing any actions.
  -v, --verbose         Enable verbose output.
  -h, --help            Show this message and exit.

Turbo speed

For the fastest possible syncs (especially in watch mode), enable SSH connection caching in your SSH config:

Host *
    ControlMaster auto
    ControlPath ~/.ssh/sockets/%r@%h:%p
    ControlPersist 600

How it works

The core of dotsync is build around efficient watching, queueing, and staging of file changes, to quickly and minimally sync changes to target hosts.

  1. File watching: in watch mode, dotsync constructs an optimistic watch-layer directory of hard links to target source files, reducing the number of OS-level file watches needed; each observed change is queued to a central processing queue
  2. Change batching: changes are batched together heuristically and as protection against rapid-fire changes; for each batch of changes, dotsync constructs a special-purpose staging-layer directory of copied/templated files to be synced

How I use dotsync

I mainly use dotsync to push a subset of my personal dotfiles to our remote dev servers. With dotsync watch, any time I change a dotfile locally it's automatically synced to all the remote servers within a second or two, no manual work needed.

My minimal dotsync config

hosts:
  devapp:
    tags: [pinterest]
    paths:
      ~/.inputrc: ~/.inputrc
      ~/.profiles.remote/pinterest.bash_aliases.bash: ~/.bash_aliases
      ~/.profiles.remote/pinterest.mise.toml: ~/.mise.toml
      ~/.scripts/pbcopy_remote.py: ~/.scripts/pbcopy

Setting a watch

# This gets run in a startup script on my local machine
dotsync watch @pinterest 2>&1 | tee -a "$LOGDIR/dotsync.log" &

See also

  • 🪄 Kuba: the magical kubectl companion
  • 🐙 Jdd: JSON diff diver — the time machine for your JSON
  • ☁️ Appa: Markdown previews with live reload
  • 🔮 PDate: human-readable dates and times

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

dotsync_fast-0.2.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dotsync_fast-0.2.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file dotsync_fast-0.2.0.tar.gz.

File metadata

  • Download URL: dotsync_fast-0.2.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.12 Darwin/24.6.0

File hashes

Hashes for dotsync_fast-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4d7124c04e8fb929ee2f17655178cd2dc0dbf82426b7668185ced0182be9f7b1
MD5 77b6b78722f0d50de573cd9907d11501
BLAKE2b-256 e9440ff444b1dd3f1df3c4948ac71911f10065643e45acbe5e6585707926164d

See more details on using hashes here.

File details

Details for the file dotsync_fast-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dotsync_fast-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.12 Darwin/24.6.0

File hashes

Hashes for dotsync_fast-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64626dc6d777e0405c8ca92e91f6ebe7da58add0857dfaae8b38eb6563ae2093
MD5 3feae4f621433521fd9a979a1db5e648
BLAKE2b-256 2da9a6f2106033951a646b3b24aefba19ca5fd6464cf7a98f0f3c01d627af251

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