HostOnNet Blog

Copying files with rsync

rsync is used to sync/copy files. If files are already present on destination, it will not copy files again, only changed or new files get copied when you run rsync.

To Copy files on same computer

rsync -a /path/to/source/ /path/to/destination/

To copy files from one server to another, run

rsync -avz --progress "-e ssh -p 3333" /home/solusvm/ root@12.36.99.136:/home/solusvm/

Copying files from remote server to local

rsync -chavzP --stats suneesh@192.168.1.5:/home/flashwebhost/Desktop/www/ /home/suneesh/www/

Rsync with exclude option

rsync -avz --delete  "-e ssh -p 3333" --exclude={dn,backup,delete} /home/ root@server70.hosthat.com:/backup/s12/home/

In the above example, folders dn, backup and delete will be ignored.

here is an example that exclude single folder, you can use multiple exclude

rsync -avz --progress --human-readable "-e ssh -p 22" --exclude=wp-content/uploads  /home/diarioti/public_html/ root@192.155.85.24:/home/diarioti/public_html/

Posted in Linux