Keeping two folders identical is a very common need: backing up documents to an external drive, a project you work on across two disks or a folder you want mirrored to a NAS. There are apps for this, but rsync comes with macOS, is fast because it only copies what changed and fits easily into a script.
Before you start
macOS rsync or openrsync
Since macOS Sequoia 15.4, the system rsync command uses openrsync, a BSD-licensed reimplementation, instead of the old Samba rsync 2.6.9 that Apple had not updated for years. For this article it behaves the same, but it does not support every option of modern rsync.
Check which one you have:
rsync --version
If you need current rsync (options like --info=progress2 or scripts that fail with openrsync), install it with Homebrew:
brew install rsync
It lands in /opt/homebrew/bin/rsync on Apple silicon Macs and /usr/local/bin/rsync on Intel Macs. Open a new Terminal window and check with which rsync that this path is used.
Disk permissions
If you sync protected folders (Documents, Desktop, external drives) and see “Operation not permitted” errors, give Terminal access under System Settings > Privacy & Security > Full Disk Access.
Step 1: basic sync
rsync -avh --progress ~/Documents/proyecto/ /Volumes/BACKUP/proyecto/
| Option | What it does |
|---|---|
-a | Archive mode: recursive copy preserving permissions, dates and symbolic links |
-v | Shows the files being copied |
-h | Readable sizes (KB, MB, GB) |
--progress | Progress of each file |
-P | Same as --progress plus --partial (resumes partial files) |
The trailing slash matters
It is the most common rsync mistake:
source/(with slash) copies the contents of the folder into the destination.source(no slash) copies the folder into the destination, creatingdestination/source/.

Always use the slash on both sides if you want the two folders identical.
Step 2: simulate before running
Before any important sync add -n (--dry-run). It shows what it would do without touching anything:

rsync -avhn ~/Documents/proyecto/ /Volumes/BACKUP/proyecto/
Step 3: exact mirror with –delete
By default rsync deletes nothing at the destination. If you want an exact mirror (what you delete at the source is deleted at the destination), add --delete:

rsync -avhn --delete ~/Documents/proyecto/ /Volumes/BACKUP/proyecto/
Careful: with
--delete, if you swap source and destination or miss a slash, you can delete files that existed only at the destination. Always run it first with-n, check thedeleting …lines and, if everything matches, remove then.
Variants: --delete-before deletes before copying (frees space first) and --delete-after deletes at the end (safer if the copy is interrupted).
Step 4: exclude files and folders
rsync -avh --delete \
--exclude '.DS_Store' \
--exclude 'node_modules/' \
--exclude '*.tmp' \
~/Documents/proyecto/ /Volumes/BACKUP/proyecto/
Note that long options have two dashes (--exclude, --delete). With many patterns, put them in a file, one per line, and use --exclude-from=excluir.txt.
Step 5: sync with another computer over SSH
rsync -avhz ~/Documents/proyecto/ user@192.168.1.50:/home/user/proyecto/
-z compresses data in transit: useful over a network, pointless between two local drives. The other machine needs rsync installed and SSH enabled.
Step 6: automate it with a script
#!/bin/bash
ORIGEN="$HOME/Documents/proyecto/"
DESTINO="/Volumes/BACKUP/proyecto/"
if [ ! -d "/Volumes/BACKUP" ]; then
echo "The BACKUP drive is not connected"
exit 1
fi
rsync -ah --delete --exclude '.DS_Store' "$ORIGEN" "$DESTINO"
Save it as sync.sh, make it executable with chmod +x sync.sh and run it with ./sync.sh. The volume check stops rsync from copying to the internal disk if the external one is not mounted.
Check that it works
Run the simulation again after syncing:
rsync -avhn --delete ~/Documents/proyecto/ /Volumes/BACKUP/proyecto/
If it lists no files, the two folders are identical. For a quick size comparison: du -sh ~/Documents/proyecto /Volumes/BACKUP/proyecto.
Common problems
Everything is copied every time even without changes. Happens with exFAT or FAT32 drives, which store dates less precisely. Add --modify-window=2 or format the destination as APFS.
“Operation not permitted”. Terminal lacks Full Disk Access (see Before you start).
A folder appears inside another (destination/proyecto/proyecto). You missed the trailing slash on the source.
An option gives “unknown option” or the script fails after a macOS update. That is openrsync, which does not support it. Install rsync with Homebrew and call it by full path in the script.
Permissions are not copied on external drives. If the drive has “Ignore ownership on this volume” enabled (Get Info in the Finder), macOS does not keep owners. Turn it off if you need them.



