Rsync Local To Local

Rsync Local To Local

Reading time1 min
#Backup#Linux#Storage#rsync#FileSync#DataManagement

Mastering rsync for Local-to-Local File Synchronization: Efficiency Beyond Network Transfers

Workstations accumulate fast-changing data sets, from development directories to photo archives. Keeping these assets sync’ed efficiently on the same machine is often overlooked; many reach for GUI backup solutions out of habit, accepting their limitations on speed, fine-grained filtering, and metadata preservation.

Rsync, written in C and available since 1996 (rsync 3.2.3 in typical modern Linux distros), offers byte-level diffing, extensive permission handling, and robust automation—all without touching the network stack.

Problem: Local Data Drift, Excessive Disk IO

Consider a 500GB project or media directory spread across multiple disks and external SSDs. Recopying everything wastes throughput, especially with large files like VM disk images or RAW photos. Add symbolic links, extended ACLs, and the need to mirror deletes, and most desktop tools fall short.

Rsync Command Structure (Local)

rsync [options] source/ destination/

The trailing slash has behavioral significance: source/ syncs contents; source syncs the directory itself.

Efficient Mirror: Preserve, Update, Prune

rsync -aAXHv --delete --progress /data/project/ /mnt/backup/project/
  • -a: archive (recursive, permissions, ownership, symlinks)
  • -A: ACLs
  • -X: xattrs
  • -H: hard links (important with deduplicated or git-annex data)
  • --delete: prune files no longer at source
  • --progress: transfer metrics

Note: If target is mounted over a slow USB 2.0 bus, IO amplification can max out the pipe. Use --bwlimit=20M to cap bandwidth without stalling other processes.

Real-World Output: Error Handling

Interrupted transfer? Rsync’s --partial avoids rehashing the entire file:

rsync -avh --partial --progress /video/footage/ /mnt/ssd-backup/footage/

Resuming interrupted 17GB .mkv files is practical here. You might see:

file.mkv
   935,040,000 100%  180.42MB/s    0:00:05 (xfr#1, to-chk=4/79)
rsync: connection unexpectedly closed (51 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(231)

Rerun with the same command: already-copied chunks are reused.

Selective Sync: Excludes, Includes, and Dirty Dirs

Filtering temp files:

rsync -a --exclude='*.tmp' --exclude='.Trash*/' /work/assets/ /mnt/backup/assets/

For a CI/CD pipeline cache, exclude node_modules/ except from a specific subdir:

rsync -a --exclude='node_modules/' --include='src/app1/node_modules/' /dev/repos/ /mnt/backup/repos/

Rsync parse order for filters is non-intuitive; test with -n (--dry-run) and inspect the proposed action list before live runs.

Permissions, Extended Attributes, and Root Context

System backups, e.g. for /etc, require elevated context. Otherwise, files owned by root will revert ownership on restore.

sudo rsync -aAXv --delete /etc/ /backup/etc-202406/

Hard links (-H) are slow with very large datasets (1M+ inodes). Profiling sync times with and without it is warranted.

Automating Syncs: Cron Integration

A minimal, robust daily job (2:30 a.m.):

30 2 * * * /usr/bin/rsync -aAX --delete /home/builduser/ /mnt/backup/builduser/

Logs from cron can go missing. Redirect output:

30 2 * * * /usr/bin/rsync -aAX --delete /home/builduser/ /mnt/backup/builduser/ >> /var/log/rsync-local.log 2>&1

Monitor log growth to avoid filling /var.

Faults, Gotchas, and Observations

  • Files deleted at source will be deleted at target with --delete—no recycle bin.
  • Some SSDs, especially in external USB-SATA enclosures, throttle or throw I/O errors under sustained rsync load.
  • FAT32/exFAT filesystems: do not preserve UNIX perms/xattrs; use ext4 or APFS as destination to avoid silent data loss.

Summary Table: Local-to-Local Rsync Use Cases

Use CaseMust-Have FlagsKnown Issues
Fast incremental backup-a, --deleteRisk of accidental deletion with mistyped path
Home directory w/ metadata-aAX, --deleteNeeds root for full metadata, may miss special files
System config backup-aAXHv, --deleteRequires root, slow on many small files
Media library-avh, --partial, --progressExternal disk I/O bottlenecks, long first sync

Non-Obvious Tip

When syncing between ZFS snapshots, using rsync --inplace interacts better with copy-on-write mechanics, minimizing snapshot delta growth.


In practice, rsync remains the most reliable method to perform local copy and sync tasks where flexibility, reproducibility, and file integrity matter. GUI-driven tools often abstract away critical details or introduce latency not present in direct command-line invocation.

Not perfect—parsing complex .rsync-filter files or using --checksum on huge directories can be slow. But for local operations, especially in scripting or infrastructure-as-code pipelines, nothing matches its blend of efficiency and control.