How to RSYNC a single file?

夏期劇場 picture 夏期劇場 · Feb 15, 2013 · Viewed 82.9k times · Source

Currently i only RSync-ing the Directories as like:

* * * * * rsync -avz /var/www/public_html/images root@<remote-ip>:/var/www/public_html

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

Answer

Michael Place picture Michael Place · Feb 15, 2013

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   --progress  /var/www/public_html/.htaccess root@<remote-ip>:/var/www/public_html/

As mentioned in the comments: since -a includes recurse, one little typo can make it kick off a full directory tree transfer, so a more fool-proof approach might to just use -vz, or replace it with -lptgoD.