A Developer In The mountains having fun

Rsync

The awesomeness of using rsync even in the current era

Rsync, short for "remote synchronization," is a popular and versatile file synchronization tool that has been around for decades. Originally developed for Unix-based systems, rsync has since been ported to a wide range of platforms, including Windows, macOS, and various Linux distributions. Rsync is still a highly relevant and useful tool today, despite the fact that it has been around for several decades.

  • Efficient use of bandwidth: One of the main advantages of rsync is its ability to transfer only the parts of files that have changedh. This means that when you use rsync to synchronize two directories, only the differences between the two directories are transferred. This can be a huge advantage when working with large files or slow connections, as it minimizes the amount of data that needs to be transferred.
  • Reliable and safe: Rsync is a highly reliable and safe tool that has been extensively tested over the years. It uses a number of techniques to ensure that data is transferred correctly, including checksums and error correction. This means that you can trust rsync to safely and accurately transfer your files, even in less-than-ideal network conditions.

  • Supports advanced copy options that few other methods do such as the ability to copy links and devices. It also can perserve owners, groups, and permissions.

  • Supports multiple protocols: Rsync supports a variety of protocols for transferring files, including SSH, FTP, and HTTP. This makes it a highly flexible tool that can be used in a variety of contexts. Whether you need to transfer files across a local network or over the internet, rsync can handle it.
  • Easy to use: Despite its power and flexibility, rsync is surprisingly easy to use. Its command-line interface is intuitive and straightforward, and there are a variety of graphical user interfaces available for those who prefer a more visual experience. Once you've set up your rsync command or script, it can be run automatically or manually, making it a great tool for automating backup and synchronization tasks.
  • Open source: Rsync is an open-source tool, which means that its source code is freely available for anyone to view, modify, and distribute. This has led to a vibrant community of developers who have contributed to its development over the years. As a result, rsync is a highly reliable and well-maintained tool that is continually being improved and updated.
  • Rsync also has a number of advanced features that make it a great choice for more complex synchronization tasks in today's world. For example, rsync can be used to synchronize files between multiple servers, to copy files over a network while preserving permissions and ownership, and to perform incremental backups that only transfer changed files.

Rsync is still a highly relevant and useful tool today. Its efficient use of bandwidth, reliability, versatility, ease of use, and open-source nature make it a great choice for file synchronization and backup tasks in a variety of contexts. Whether you're a sysadmin, a developer, or a casual user, rsync is a tool that is definitely worth considering.

rsync use in practice

Basic rsync syntax

rsync <options> <source> <destination>

some options I find useful

  • v — verbose
  • r — recursive (does not preserve timestamps and permissions)
  • a — archive mode (recursive with preserving everything)
  • z — zip/compress the data
  • h — human readaable output
  • e — use an external program such as ssh
  • info=progress2 — shows a nice progress indicator for full xfer
  • progress — shows progress & time remaining of each file
  • -–dry-run — doesn't change any files, allows you to test out the command in essence before you pull the trigger

How i use sshpass with rsync in a script to automate pushing my website up to the remote host:

I have to do this because my current host doesn't support passwordless keys to be used.

sshpass -p 'myPassphrase' rsync -azh --info=progress2 -e 'ssh -p 7836' /home/tkoefod/Repos/devinthemtnWebSite/out/ remoteUser@remote.com:~/devinthemtn.com/

more on sshpass

More places to find me
follow me on Mastodon