Giter Site home page Giter Site logo

mirror.py's Introduction

mirror.py

A simple rsync mirroring tool. JSON configuration. Written in Python.

Usage

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)

Examples

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

Configuration

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 run rsync using the rsync network protocol.
  • mirror_ssh_example.json demonstrates how to configure the script to run rsync using the ssh network protocol.

Contributing

Contributions are welcome! Please submit a pull-request, including unit test coverage.

Development Environment

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

Testing

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

mirror.py's People

Contributors

f1337 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.