Rsync File Transfer & Backup

Dec 4th 2026 — rsync, backup, transfer, linux, ssh, terminal

Local File Sync

rsync is faster and safer than cp or scp for large transfers because it only copies changed blocks and supports resuming.

# Standard copy with progress bar and permissions preserved
rsync -avhP /source/dir/ /destination/dir/

# Mirror directory (deletes files in destination that no longer exist in source)
rsync -avhP --delete /source/dir/ /destination/dir/

📌 Note: A trailing slash (/source/dir/) copies the contents of the folder. Without it (/source/dir), it copies the folder itself.

Remote Transfer over SSH

# Push local files to a remote server
rsync -avhP -e ssh /local/path/ user@remote_ip:/remote/path/

# Pull files from a remote server (custom SSH port)
rsync -avhP -e "ssh -p 2222" user@remote_ip:/remote/path/ /local/path/

Useful Flags & Dry Run

# Test the command without actually copying/deleting anything
rsync -avhP --dry-run /source/ /destination/

# Exclude specific folders or file types
rsync -avhP --exclude 'node_modules' --exclude '*.log' /source/ /destination/