Skip to content

rsync

rsync is a fast, incremental file transfer tool for Unix-like systems that synchronizes data locally or over SSH while minimizing bandwidth usage


Mirror a directory locally (exact copy, including deletions)

rsync -av --delete source_dir/ target_dir/

Dry-run synchronization (see what would change)

rsync -av --delete --dry-run source_dir/ target_dir/

Sync over SSH with compression enabled

rsync -avz -e ssh source_dir/ user@remote:/backup/source_dir/

Preserve permissions, ownership, ACLs, and extended attributes

rsync -aAX source_dir/ target_dir/

Resume interrupted transfers (large files)

rsync -av --partial --progress source_dir/ user@remote:/data/

Exclude files and directories using patterns

rsync -av --exclude='.git/' --exclude='*.log' source_dir/ target_dir/

Use an exclude file for complex rules

rsync -av --exclude-from=exclude.txt source_dir/ target_dir/

Limit bandwidth usage during transfer

rsync -av --bwlimit=2000 source_dir/ user@remote:/backup/

Copy only newer files (incremental updates)

rsync -av --ignore-existing source_dir/ target_dir/

Create incremental backups using hard links

rsync -a --delete --link-dest=/backups/latest source_dir/ /backups/$(date +%F)/

Efficient and Secure File Synchronization with rsync over SSH (chacha20-poly1305)

rsync -r --delete --stats -i \                                                                                                                                                                                                                           
  -e 'ssh -T -o Compression=no -c chacha20-poly1305@openssh.com' \
  --no-perms --no-owner --no-group --omit-dir-times --no-times \
  source_path \
  username@server.com:~/some_folder