Backing up using rsync


I have always wanted to understand the best possible way of backing up a drive using rsync, either to another external drive, or to a Linux server.

Backing up to another external drive

For backing up to another external drive on macOS, one must first install the latest version of rsync (v3.4.2 as of May 2026):

brew install rsync

and then add the terminal in which rsync is run to Full Disk Access in Settings | Security and Privacy.

To start the backup process, run the command:

sudo /opt/homebrew/bin/rsync -aHAX --delete --info=progress2 \
  --exclude=".Spotlight-V100/" \
  --exclude=".fseventsd/" \
  --exclude=".Trashes/" \
  --exclude=".TemporaryItems/" \
  --exclude=".DocumentRevisions-V100/" \
  "/Volumes/SourceDrive/" \
  "/Volumes/DestinationDrive/"

The meaning of -aHAX is:

-a   archive mode
-H   hard links
-A   ACLs
-X   extended attributes, including many macOS metadata attributes

To verify the backup, run:

sudo /opt/homebrew/bin/rsync -aHAX --delete --info=progress2 --checksum --dry-run \
  --exclude=".Spotlight-V100/" \
  --exclude=".fseventsd/" \
  --exclude=".Trashes/" \
  --exclude=".TemporaryItems/" \
  --exclude=".DocumentRevisions-V100/" \
  "/Volumes/SourceDrive/" \
  "/Volumes/DestinationDrive/"

Backing up between two Ubuntu Linux servers

It is more involved to backup between two Ubuntu Linux servers. On the source server, I had to run:

echo 'bli ALL=(root) NOPASSWD: /usr/bin/rsync' | sudo tee /etc/sudoers.d/99-rsync-bli
sudo chmod 440 /etc/sudoers.d/99-rsync-bli
sudo visudo -cf /etc/sudoers.d/99-rsync-bli

where bli is the username. This makes sure that rsync can run with sudo access when copying from the source server.

On the destination server, I had to run:

sudo --preserve-env=SSH_AUTH_SOCK rsync -aHAX --numeric-ids --info=progress2,flist2 \
--rsync-path="sudo rsync" -e "ssh -i /home/bli/.ssh/id_rsa" bli@SOURCE_IP_ADDR:/data/ /data/

To copy from the source server (with its IP address as SOURCE_IP_ADDR)‘s /data directory to the destination server’s /data.