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
?
With Rsync, you can copy a single file, multiple files, and directories to a remote system. For copying files and directories remotely, you will require: Rsync installed on both local and remote system.
Rsync is a great tool to use when you're moving large files between a server. Reclaim uses it often when working through migrations. To start, you'll want to make sure you're logged into the server where the content currently is.
Conclusion: Rsync is a tool that can improve the reliability of local directory syncing and the file transfer process over remote systems. You can use the rsync command to create complex backups and smooth control over what and how a directory will sync.
By default, rsync will only copy new or changed files from a source to a destination. The –update or -u option is used by rsync to skip files that are still new in the destination directory. Also, –dry-run or -n enables us to execute a test operation without making any changes.
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
.
Basic syntax
rsync options source destination
Example
rsync -az /var/www/public_html/filename root@<remote-ip>:/var/www/public_html
Read more
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With