💾

Rsync Overview and Usage

Jun 20, 2025

Overview

This lecture covers the installation, usage, and advanced features of rsync for file transfer, backup, and system migration, focusing on practical command options and important caveats.

Installation & Front-ends

  • Install rsync using your package manager on both source and destination machines.
  • GUI front-ends include Grsync (GTK), luckyBackup (Qt), and nbRsync (JavaFX).
  • Other tools using rsync: rdiff-backup, osync, yarsync.

Basic Usage & Options

  • Use rsync -P source destination for copying files, showing progress and resuming partial transfers.
  • Use -r/--recursive for directories.
  • Remote copying uses the SSH protocol by default (host:destination syntax).
  • rsync creates a file list and only transfers changed file blocks using checksums.
  • Useful aliases: cpr() for copying, mvr() for moving, both using sensible default options.

Trailing Slash Caveat

  • Adding a slash to the source directory changes destination structure: rsync -r source/ dest copies contents directly; rsync -r source dest creates a subdirectory.
  • Use scripts or care to avoid accidental overwrites due to trailing slashes.

Backup Utility

  • Simple scheduled backup: rsync -a --delete --quiet /src /dest.
  • Use -e ssh for remote backups: rsync -a --delete --quiet -e ssh /src user@host:/dest.
  • For automated backups, scripts can be triggered by cron, NetworkManager, or systemd/inotify.
  • Differential backups: use --inplace --backup --backup-dir=/incr/$DAY for daily differential copies.
  • Snapshot backups: use --link-dest for hardlinked, space-saving snapshots.

Full System Backup & Restore

  • Full backup: rsync -aAXHv --exclude=... / /backup preserves links, ACLs, xattrs, and skips specified dirs.
  • Exclude system, cache, bind mounts, swap files, and GVFS errors.
  • Restore by reversing source and destination; remove --exclude options for full restore.

Advanced Filtering & Files-from

  • Use a filter file with --filter="merge backup.filter" for complex include/exclude patterns.
  • Use --files-from=file.txt with a list of paths for custom file selection (add -r for recursion).

File System Cloning

  • For full filesystem cloning: rsync -qaHAXS SRC/ DEST/ preserves hard links, ACLs, xattrs, and sparse files.
  • Use trailing slash to avoid directory nesting issues.

Running as a Daemon

  • Start rsyncd.service for network file serving on port 873.
  • Configure /etc/rsyncd.conf with shares and include/exclude lists.
  • Data is not encrypted; consider client authentication and firewall settings.

Key Terms & Definitions

  • rsync — Utility for fast incremental file transfers.
  • Archive mode (-a) — Preserves permissions, links, timestamps, owner, and group.
  • Checksum — Integrity check used to transfer only changed file blocks.
  • Snapshot backup — Incremental backup using hardlinks to save space.
  • Daemon mode — Running rsync as a background network server.

Action Items / Next Steps

  • Install rsync and any desired front-ends.
  • Try basic rsync commands for local and remote copying.
  • Set up and test a backup script suitable for your use-case.
  • Review the trailing slash caveat before copying directories.
  • Explore advanced filtering or daemon mode as needed.