Home » Linux » How to RSYNC a single file?

How to RSYNC a single file?

Posted by: admin December 7, 2017 Leave a comment


Currently i only RSync-ing the Directories as like:

* * * * * rsync -avz /var/www/public_html/images [email protected]<remote-ip>:/var/www/public_html

So how do i rsync one single file like, /var/www/public_html/.htaccess ?


You do it the same way as you would a directory, but you specify the full path to the filename as the source. In your example:

rsync -avz /var/www/public_html/.htaccess [email protected]<remote-ip>:/var/www/public_html/


Basic syntax

rsync options source destination


rsync -az /var/www/public_html/filename [email protected]<remote-ip>:/var/www/public_html

Read more


Michael Place’s answer works great if, relative to the root directory for both the source and target, all of the directories in the file’s path already exist.

But what if you want to sync a file with this source path:


to a file with the following target path:


and the directories a and b don’t exist?

You need to run an rsync command like the following:

rsync -r --include="/a/" --include="/a/b/" --include="/a/b/file" --exclude="*" [source] [target]