Arshad Mehmood

Search the blog

    Today I Learned

    Using rsync for file transfers

    ssh

    rsync synchronizes files over SSH, with smart incremental copying (only transfers changed parts). Syntax: rsync [options] source destination

    See also: Using scp for file transfers — comparison below.

    Local to remote

    Copy a single file to remote:

    rsync -avz ./local-file.txt user@hostname:/path/to/remote/

    Copy a folder to remote:

    rsync -avz ./local-folder/ user@hostname:/path/to/remote/

    Remote to local

    Download a single file from remote:

    rsync -avz user@hostname:/path/to/remote/file.txt ./local-folder/

    Download a folder from remote:

    rsync -avz user@hostname:/path/to/remote/folder/ ./local-folder/

    Remote to remote

    Sync between two remote servers:

    rsync -avz --rsh=ssh user1@host1:/path/src/ user2@host2:/path/dest/

    Common options

    • -a — Archive mode (preserves permissions, times, etc.)
    • -v — Verbose
    • -z — Compress during transfer
    • -r — Recursive
    • --delete — Delete files in destination not in source
    • --exclude=pattern — Skip matching files
    • --dry-run — Preview without copying

    rsync vs scp

    Featurersyncscp
    Incremental✅ (only changed parts)❌ (full copy)
    Resume✅ (can restart)❌ (restarts from beginning)
    BandwidthBetter (compression, skips unchanged)Basic
    SpeedFaster for repeated syncsFaster for one-time small files
    ComplexityMore options, steeper learning curveSimple, straightforward

    Use rsync for backups and large repeated syncs. Use scp for quick one-off file transfers.