Skip to content

Remote Sync (rsync)🔗

While scp is a great tool for copying files between systems, rsync is even better. rsync is a utility for efficiently transferring and synchronizing files across computer systems, by checking the timestamp and size of files.

  • This makes it much faster than scp when transferring large files or directories.
  • This also makes it ideal for large transfers that might be interrupted, as rsync can resume where it left off.

Rsync comes preinstalled by default on Unix-based systems (Linux, macOS), and can be accessed on Windows using WSL.

Basic Usage🔗

To copy a file from a remote server to your local machine:

rsync -avz username@remote:/path/to/remote/file /path/to/local/destination

To copy a file from your local machine to a remote server:

rsync -avz /path/to/local/file username@remote:/path/to/remote/destination

To copy a directory from your local machine to a remote server:

rsync -avz /path/to/local/directory username@remote:/path/to/remote/destination

This document provides a brief overview of rsync, its commonly used arguments, and basic usage examples.

Advanced Usage🔗

Commonly Used Arguments🔗

  • -a: This is a quick way of saying you want recursion and want to preserve almost everything.
  • -v: Verbose mode. rsync will print what it's doing.
  • -z: Compress file data during the transfer.
  • -P: Show progress during transfer and keep partially transferred files which is useful for large files.
  • -e ssh: Use SSH for the data transfer.

Try it yourself🔗

Copy a file from the h4hdata node to your local machine's home directory

Solution
rsync -avz -e ssh -P $H4HDATA_PORT "<username>@$H4HDATA:/path/to/remote/file" $HOME/

For more information on rsync, you can check the manual page with man rsync or visit the rsync website.