Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to RSYNC a single file?

Tags:

file

linux

rsync

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 ?

like image 950
夏期劇場 Avatar asked Feb 15 '13 03:02

夏期劇場


People also ask

Can you rsync a single file?

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.

Can rsync move files?

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.

Can you rsync a directory?

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.

Does rsync only copy changed files?

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.


2 Answers

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.

like image 102
Michael Place Avatar answered Sep 20 '22 17:09

Michael Place


Basic syntax

rsync options source destination 

Example

rsync -az /var/www/public_html/filename root@<remote-ip>:/var/www/public_html 

Read more

like image 44
Techie Avatar answered Sep 16 '22 17:09

Techie