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,
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/
rsync options source destination
rsync -az /var/www/public_html/filename [email protected]<remote-ip>:/var/www/public_html
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]