dired-sync

Homepage: https://github.com/renard/dired-sync

Updated:

Summary

Sync directories within dired

Commentary

dired-sync provide a simple and easy way to synchronize directories from
dired. This tool is based upon both rsync(1) and ssh(1).

To install `dired-sync' you simply need to drop dired-sync.el in your
load-path and bind (suggested) C-s S key to `dired-do-sync':

(when (require 'dired-sync nil t)
  (define-key dired-mode-map (kbd "C-c S") 'dired-do-sync))

Synchronizations can also be done using pools (seed `dired-do-sync-pool'.
For this to work `dired-sync-pools' needs to be configured. To bind
`dired-do-sync-pool' to C-c s add this in previous sexp:

(define-key dired-mode-map (kbd "C-c s") 'dired-do-sync-pool)

There are 3 types of directories synchronizations as explained bellow.

* local / local
  This is the easiest way. rsync(1) would be enough.

* local / remote or remote / local
  This is also a simple way, the only requirement is a working ssh
  connection to the remote host.

* remote / remote
  This is a bit more complexe since there are 3 types of remote / remote
  syncs.
  - source server can reach destination server
    In that case `dired-sync' would optimize files synchronisation by
    running rsync(1) on the source server through a ssh connection.
  - source server cannot reach destination server
    This is the more complexe case. `dired-sync' would create a ssh
    tunnel from source to destination using your local machine as a
    jumphost.
    Be aware this mode is greedy regarding bandwidth consumption since
    data are transfered twice: from the source server to localhost AND
    from localhost to destination server.
  - Both source and destination are located on the same remote host.
    This case is the same as the first one (source server can reach
    destination server) except the destination directory is local (on the
    remote host).
 If a direct connection could not be established from source to
 destination, `dired-sync' would automatically fall back to the tunneled
 sync mode.

 `dired-sync' is heavily based on ssh(1) configuration hence your
 ~/.ssh/config file should be as accurate as possible. It doesn't matter
 how many jumphosts you need to use to reach both source and destination
 as long as they are declared in you ssh configuration file.

 To allow `dired-sync' to work out of the box, key-based ssh
 authentication is required.

     Source                       Destination

   +---------+   (if possible)    +---------+
   |  HostA  |<- - - - - - - - - >|  HostB  |
   |  UserA  |                    |  UserB  |
   +---------+                    +---------+
        ^                              ^    
   +---------+                    +---------+
   |JumphostA|                    |JumphostB|
   | UserJHA |                    | UserJHB |
   +---------+                    +---------+
        ^                              ^
        |          +---------+         |
        -----------|localhost|----------
                   +---------+
	      
To use that configuration, you ~/.ssh/config may be something like:

  Host *
       ForwardAgent yes
       RhostsRSAAuthentication yes
       RSAAuthentication yes
       HashKnownHosts yes
       IdentityFile ~/.ssh/id_rsa
       TCPKeepAlive yes
       ServerAliveInterval 30
       Port 22
       Protocol 2,1

  Host jumphostA
       User userJHA
       HostName jumphostA.example.com

  Host hostA
       User userA
       HostName jumphostA.internal.example.com
       ProxyCommand ssh -q -t jumphostA  nc -w 1 %h %p

  Host jumphostB
       User userJHB
       HostName jumphostB.other-example.com

  Host hostB
       User userB
       HostName jumphostV.internal.other-example.com
       ProxyCommand ssh -q -t jumphostB  nc -w 1 %h %p


then you would be able to connect to hostA by simply typing:

   ssh hostA

Or opening a dired buffer to hostB: C-X C-f /scp:hostB:

Dependencies

Reverse dependencies