Use a custom SSH port and excludes

Connect over a custom SSH port and skip paths from excludes.txt (.git, node_modules, *.tmp)

rsync -a -e "ssh -p 2222" --exclude-from=excludes.txt /src/ user@<host>:/dst/

tool
rsync7 commands
tags
rsyncnetworkci

More rsync commands

  • rsync -ac --delete-after /src/ /dst/

    Compare files by checksum, not by mtime and size. --delete-after removes files only after the transfer

  • rsync -aHAXv --numeric-ids /src/ user@<host>:/dst/

    Keeps hard links, ACLs, xattrs and numeric uid/gid when you move to a new host. Note: the trailing slash matters

  • rsync -ai --dry-run --delete /src/ /dst/

    Show every change with itemize codes (>f, cd, *deleting) before any file is touched

  • rsync -a --bwlimit=10M --info=progress2 /src/ user@<host>:/dst/

    Cap bandwidth at 10 MB/s so the link is not saturated. progress2 shows total progress and ETA

  • rsync -a --delete --link-dest=../prev /src/ ./$(date +%F)/

    Time Machine style backups: unchanged files are hard links to prev, only changes take new space

all 7 rsync commands