Install rsync for transferring files

Use any one of the following commands to install rsync. If you are using Debian or Ubuntu Linux, type the following command:

apt-get install rsync

RHEL / CentOS 5.x or newer user type the following command:

yum install rsync -y

Since rsync does not provide any security while transferring data it is recommended that you use rsync over ssh session. This allows a secure remote connection.

Example of commands

Copy file from a remote server to a local computer:

rsync -v -e ssh [email protected]:~/file.html /tmp

Synchronize a local directory with a remote directory:

rsync -r -a -v -e "ssh -l root" --delete /local/folder server.server.tld:/folder

Synchronize a remote directory with a local directory:

rsync -r -a -v -e "ssh -l root" --delete server.server.tld:/folder/ /local/folder

Synchronize a local directory with a remote rsync server or vise-versa:

rsync -r -a -v --delete rsync://sync.server.server.tld/folder /home/folder

Mirror a directory between my "old" and "new" web server/ftp:
rsync -zavrR --delete --links --rsh="ssh -l root" my.old.server.tld:/home/folder /home/folder

Comments

  • JJussiJJussi Member
    Hi!
    -e "ssl -l root" parameter is not needed when you use "ssh syntax" with addresses. So we can change:
    rsync -v -e ssh [email protected]:~/file.html /tmp   
    to:
    rsync -v [email protected]:file.html /tmp
    (note that ~/ is missing too because : is pointing automatically to users home directory)

    Normally I use:
    rsync -aP [email protected]:file.html /tmp
    so ownership, modification time and so on is preserved.
Sign In or Register to comment.