monitored_rsync

command module
v0.0.0-...-ef76c34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 12 Imported by: 0

README

monitored_rsync

This simple command line tool simply call a inotifywait on a directory (recursively tracking subdirectories) and whenever there is a change, it calls rsync.

There are many uses for this, including a live backup system, a synchronizing way to develop on a local machine (let's say a laptop), and have the code sync'ed up to a server, where presumably compilation happens. Notice this is often better than something like sshfs because it has a copy of all files locally, which greatly speeds up IDEs (sshfs over high-latency connections is annoying to develop, specially for IDEs that are constantly checking if files changed).

Installation

$ go install github.com/janpfeifer/monitored_rsync@latest

Note: prefix with GOPROXY=direct if you want to make sure it is getting the latest version.

Example:

$ monitored_rsync --exclude=.git,.idea ~/Projects/MyProject me@myhost:Projects/MyProject

More options

From --help:

Usage of monitored_rsync:
$ monitored_rsync [flags...] <source_directory> <remote_target>
                                           
  It monitors changes in directories using inotifywait, and when changes happen, it invokes rsync.                                              
                                           
  <source_directory>: where to monitor and rsync from.    
  <remove_target>: passed to rsync
                                                                                                                                                                              
  Use '--vmodule=rsync=2' to see the rsync command executed. And use '--vmodule=monitor=2' to see file change
  events received.                                                                                                                                                            
                                           
  -delay int
        Time in milliseconds to wait for changes, before invoking rsync. This is usually efficient because changes to files usually happen in burst, and we want to avoid mult
iple rsync invocations. (default 1000)
  -dry-run
        If set to true, it will run rsync in dry-run mode.
  -exclude string
        List (comma-separated) of subdirectories (from the source directory) to exclude from monitoring and rsync.

(Various logging flags omitted)

TODO

The rsync flags are hard-coded for now :( -- except the --exclude and --dry-run. Someone should create a flag to make it configurable.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL