Two Way rsync via SSH

From D3xt3r01.tk
Revision as of 11:50, 16 December 2012 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

WHY

Because I need to keep in sync some servers with the same content...

HOW

1) Password-less SSH Login

2)

rsync -e 'ssh -ax -p PORT -l USER -i /path/to/rsync-key' -avzurP /path/to/source/ REMOTE_HOST:/path/to/destination/
rsync -e 'ssh -ax -p PORT -l USER -i /path/to/rsync-key' -avzurP REMOTE_HOST:/path/to/destination/ /path/to/source/

Another example would be trying to backup your '/overlay' partition from an openwrt box. Keep in mind you need rsync on the openwrt box too or you'll be greeted with this error:

ash: rsync: not found
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: remote command not found (code 127) at io.c(605) [Receiver=3.0.9]

Here it is ... without the rsync-key

rsync -HDgopt -e 'ssh -ax -p PORT -l USER' -avzurP 192.168.1.1:/overlay/ /path/to/destination/