file-sync intermediate

rsync

A fast, versatile file-copying tool that syncs files and directories locally or over SSH, transferring only the differences between source and destination.

What it is

rsync is a command-line utility for copying and synchronizing files and directories, either locally or over a network via SSH. Its delta-transfer algorithm compares source and destination and only sends the parts of files that actually changed, making repeat syncs of large directories fast and bandwidth-efficient compared to a plain copy.

Why I use it

It’s my go-to for server backups, mirroring directories between machines, and pushing updated files to a remote host without re-uploading everything each time. The --dry-run flag also makes it safe to preview exactly what a sync will do before committing to it — useful when --delete is involved.

Installation

# Debian / Ubuntu
sudo apt install rsync

# RHEL / Rocky / AlmaLinux
sudo dnf install rsync

# Arch
sudo pacman -S rsync

Common usage

# Sync a local directory, preserving permissions/timestamps, with progress output
rsync -avh /source/dir/ /destination/dir/

# Sync to a remote host over SSH
rsync -avz -e ssh /source/dir/ user@remote:/destination/dir/

# Preview what would happen without copying anything
rsync -avh --dry-run /source/dir/ /destination/dir/

# Mirror a directory, deleting files at the destination that no longer exist at the source
rsync -avh --delete /source/dir/ /destination/dir/

Key flags

Note: trailing slashes on the source path matter. dir/ copies the contents of dir, while dir (no slash) copies the folder itself into the destination.