A simple rsync mirroring tool. JSON configuration. Written in Python.
usage: mirror.sh [-h] [--version] [-n] [-v] [--config CONFIG]
{pull,push} [target [target ...]]
positional arguments:
{pull,push} "pull": remote to local or "push": local to remote
target Target(s) to sync (default: all configured targets)
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
-n, --dry Dry run (do not transfer any files)
-v, --verbose Print debug output (noisy)
--config CONFIG Configuration file (default:
~/.config/mirror.py/mirror.json)
Push local changes to remote:
mirror.sh push
Pull local changes from remote:
mirror.sh pull
Preview changes before pushing or pulling:
mirror.sh pull --dry --verbose
mirror.sh push -nv
List changed files as they are transferred:
mirror.sh pull -v
mirror.sh push --verbose
Two sample configurations are provided in examples. Copy one to ~/.config/mirror.py/mirror.json
and customize to your liking:
mirror_rsync_example.json
demonstrates how to configure the script to runrsync
using thersync
network protocol.mirror_ssh_example.json
demonstrates how to configure the script to runrsync
using thessh
network protocol.
Contributions are welcome! Please submit a pull-request, including unit test coverage.
A Vagrantfile
has been provided for ease of development.
Vagrant will install pip
and dev dependencies in an Ubuntu VM:
vagrant up
vagrant ssh
cd /vagrant
Alternately, install the dev dependencies via pip
:
pip install -r requirements-dev.txt
mamba --format documentation
Mirror
invalid config file
✓ it raises IOError
valid config file
.flags()
✓ it returns the configured value
.pull("leg")
✓ it returns the remote-to-local command for "leg"
.push("button")
✓ it returns the local-to-remote command for "button"
.target("leg")
✓ it returns the target "leg"
.targets()
✓ it returns all the configured targets
.targets(["button", "finger"])
✓ it returns the "finger" and "button" targets *only*
.dry_run = True
.flags()
✓ it returns the configured value plus "n"
.verbose = True
.flags()
✓ it returns the configured value plus "v"
9 examples ran in 0.0137 seconds