Last reviewed
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 changed. 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 to verify each file after it is transferred. 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.
- Works locally and over the network: Rsync can copy between local directories, over SSH (or another remote shell), or by connecting to an rsync daemon (
rsync://). It doesn't transfer over FTP or HTTP. 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
Keep rsync up to date
Rsync 3.4.0 (January 2025) fixed six security vulnerabilities, including a serious one that could be exploited with only anonymous read access to an rsync server. Use version 3.4.1 or newer, which also fixes regressions from 3.4.0. You can check yours with rsync --version.
How to automate pushing a website up to a remote host
If your host supports SSH keys, use them. Rsync needs nothing extra:
rsync -azh --info=progress2 -e 'ssh -p 2222' ./out/ remoteUser@remote.example.com:~/mysite/
If your host doesn't support SSH keys you can use sshpass in a script. Don't use sshpass -p, as it puts the password on the command line where it can be seen in the process list and your shell history. Have it read the password from the SSHPASS environment variable with -e instead:
sshpass -e rsync -azh --info=progress2 -e 'ssh -p 2222' ./out/ remoteUser@remote.example.com:~/mysite/

