bible:~/www # rsync -avrz -e ssh www.palmcoder.net:/var/www/palmcoder/blogimages . receiving file list ... done blogimages/
blogimages/DSCN0156.thumb.jpg blogimages/DSCN0191.thumb.jpg blogimages/DSCN0718.jpg blogimages/dscn0456.jpg blogimages/palmcoder.gif wrote 96 bytes read 92643 bytes 10910.47 bytes/sec total size is 96350 speedup is 1.04
You can see that we have chosen to copy a single small directory with multiple files. In this example, the rsync command uses the parameters -azrv that correspond to the following:
♦ -a —Enables an archive mode that keeps all of the file attributes of the files you are copying.
♦ -v —Verbose mode prints out so you can see the files you are copying.
♦ -r — Recursive copying traverses the directory structure of the directory you are copying.
In this example, we have also told rsync to use ssh to connect to the server. You do have an rsync server that can be used, but most people just use ssh to transport data because many servers are running ssh and not the rsync server.
Note In the example, when specifying the server (www.palmcoder .net), we also specified the directory to copy over, separated by a colon (:). As we have not put a forward slash (/) at the end of the bl ogimages directory, rsync copies the directory and its contents to our local machine. If a forward slash were added to the directory specified, we would copy only the contents of the directory and not the directory itself. Be very wary about this because it is easy to copy something you were not expecting if you miss a forward slash.
If you want to make sure any files that were deleted from the server you were synchronizing from were actually deleted on the local machine when synchronized, you need to add the -delete parameter to the command-line options.
Was this article helpful?