Skip to content

rsync

  • Utility for transferring and synchronizing files within same computer or to a remote computer
  • Compares the modification time and size of the files
  • Rsync is a lot faster than ftp or scp
  • Used mostly to backup files
  • Port 22 (same as SSH)
  • Rsync uses SSH to transfer the files!
rsync -zvh "/local/source/file.txt" "/local/destination/folder" # Local file sync
rsync -azvh "/local/source/folder" "/local/destination/folder" # Local directory sync

rsync -avz "/local/source/file.txt" "user@ip:/remote/destination/folder" # Push to remote server
rsync -avzh "user@ip:/remote/source/file.txt" "/local/destination/folder" # Pull from remote server

# Local sync
tar -cvf backup.tar /home/hvitoi
mkdir /tmp/backups
rsync -zvh /home/hvitoi/backup.tar /tmp/backups # sync the file in the home and backups dirs
rsync -azvh /home/hvitoi/hvitoi /tmp/backups  # sync the folder

# Remote sync
mkdir /tmp/backups # folder on remote server
rsync -avz /home/localfile [email protected]:/home/hvitoi/remote/folder # sync file to remote server
rsync -avzh [email protected]:/home/hvitoi/serverfile /home/local/folder
rsync -avh \
  --progress \
  --exclude=sources/install.wim \
  /Volumes/CCCOMA_X64FRE_PT-BR_DV9/ \
  /Volumes/WINDOWS_USB/