This is a simple script that will rsync down a directory tree from a remote system, via ssh, and then keep the remote copy in sync with the local copy using lsyncd, as you edit it. In each case, the newest version of the file is always kept. It is intended for cases when editing remotely is too uncomfortable, and git pull/push is too manual.
lsyncd uses inotify to watch folders efficiently, for changes, new files, etc. It then mirrors those changes on the server using ssh commands, and/or rsync to upload file deltas.
Once the initial sync is complete, the synchronization is not bidirectional.
If a change is made to the remote copy, then mirror <name>
will pull down
those changes.
An external exclude_list
file is used to control the download sync,
and lsyncd's exclude_cvs
option is used the control the upload sync.
All the mirrors live in $HOME/mirrors/<name>
.
mirror resume
- First, kill any existing lsyncd processes
- Then, rsync all newer files from the server.
- Finally, restart all client-to-server lsyncd daemons.
mirror <name>
- Like "resume", but for a specific mirrored folder
mirror <name> <host:directory> [init]
- Rsync the remote directory, minus VCS data, to ~/mirrors/.
- And start lsyncd to keep the remote files up-to-date with local changes.
- Append "init" to have it overwrite local changes