Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 1.08 KB

rsync.md

File metadata and controls

50 lines (34 loc) · 1.08 KB

Rsync

One-Way Sync

rsync -avz --delete <user>@<server>:/home/user/ /home/user/
  • -a: archive mode
  • -v: increase verbosity
  • -z: compress file data during the transfer
  • --delete: delete extraneous files from dest dirs
  • --exclude=PATTERN: exclude files matching PATTERN
  • --info=progress2: statistics
  • --dry-run / -n: trial run

Jump Host

  • -e: specify the remote shell to use

Copy from srv01.example.com to local over jump01.example.com:

rsync -avz -e "ssh -J user@jump01.example.com" user@srv01.example.com:/path/to/source/ /path/to/target/

Change Owner

Changes owner of the data:

rsync -avz --delete --chown=user02:user02 /home/user01/www/ /home/user02/www/

Mass Delete

If you want to delete a directory with several million files, rm -rf folder is extremely slow. rsync is faster.

mkdir empty
rsync -a --delete empty/ folder/

Sudo

If user@srv01.example.com only can read the data with sudo:

rsync -avz --rsync-path="sudo rsync" user@srv01.example.com:/source/path /target/path