[SOLVED] How to RSYNC a single file?

Issue

This Content is from Stack Overflow. Question asked by NicoHood

I basically want to do this:

In my specific usecase I want to get a database dump from another server and directly import it to the local machines database.

Using other tools than rsync is no option, as I’ve restricted the ssh shell to only use rrsync, which is a handy tool to restrict file access to different locations. This makes it easy for me to restrict the files that rsync can copy or modify. If you can do that restriction without rrsync, then other options like scp would also work.

I found no way to do it without a temporary file, any ideas?



Solution

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.


This Question was asked in StackOverflow by 夏期劇場 and Answered by Michael Place It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?