Rsync: Difference between revisions

Rsync
No edit summary
add jump host section + logo
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:rsync}}
{{DISPLAYTITLE:rsync}}
[[File:Newrsynclogo.png|thumb]]
[[wp:rsync]] (Remote Synchronization) is a utility for efficiently transferring and synchronizing files across computer systems, by checking the timestamp and size of files; and optionally a checksum comparison. It is commonly found on Unix-like systems and functions as both a file synchronization and file transfer program. The rsync algorithm is a type of delta encoding, so that only file differences are transmitted across the network. Zlib may be used for additional compression, and SSH or stunnel can be used for data transport security.
[[wp:rsync]] (Remote Synchronization) is a utility for efficiently transferring and synchronizing files across computer systems, by checking the timestamp and size of files; and optionally a checksum comparison. It is commonly found on Unix-like systems and functions as both a file synchronization and file transfer program. The rsync algorithm is a type of delta encoding, so that only file differences are transmitted across the network. Zlib may be used for additional compression, and SSH or stunnel can be used for data transport security.


Line 24: Line 25:


(On machineA)
(On machineA)
<code>sudo --preserve-env=SSH_AUTH_SOCK rsync -vrz --checksum /var/discourse root@machineB:/var</code>
<code>sudo --preserve-env=SSH_AUTH_SOCK rsync -vrz --checksum /var/discourse root@machineB:/var</code>
will successfully read all files on MachineA using elevated privileges of sudo, and transfer them to MachineB
will successfully read all files on MachineA using elevated privileges of sudo, and transfer them to MachineB


Note: to make a permanent configuration in sshd_config, you'd use something like this<ref>http://serverfault.com/questions/107187/ssh-agent-forwarding-and-sudo-to-another-user</ref>:
Defaults>root    env_keep+=SSH_AUTH_SOCK
== Jump through bastion host using ssh ==
If you're working on a remote terminal  and your repository get's complicated, but you don't have desktop tools like [[meld]] or [[gitk]] on the remote host to examine things, you can copy the remote repo to your desktop with <code>rsync</code>, even if you have to jump through a bastion host with something like:<syntaxhighlight lang="bash">
rsync -e "ssh -t bastion ssh -A" -ravz centos@10.0.50.68:/opt/meza/ ./meza-es1/
</syntaxhighlight>If that complains about host-key verification, then simply do an SSH first to the bastion host, accept the host key identity, and logout.  Now the rsync will work because the host-key is already accepted as valid.


{{References}}
{{References}}