How does scp differ from rsync

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

https://www.digitalocean.com/community/articles/how-to-host-ghost-with-nginx-on-digitalocean https://www.digitalocean.com/community/articles/how-to-host-ghost-with-nginx-on-digitalocean

scp -r ghost-0.3 root@*your-server-ip*:~/

http://railscasts.com/episodes/339-chef-solo-basics?view=asciicast http://railscasts.com/episodes/339-chef-solo-basics?view=asciicast

 scp -r root@178.xxx.xxx.xxx:/var/chef .

In the same Railscast, when the author wants to copy files to the remote server (same direction as the first example), he uses rsync:

rsync -r . root@178.xxx.xxx.xxx:/var/chef

Why use the rsync command if scp will copy in both directions? How does scp differ from rsync?

Answers

The major difference between these tools is how they copy files.

scp basically reads the source file and writes it to the destination. It performs a plain linear copy, locally, or over a network.

http://rsync.samba.org/tech_report/ http://rsync.samba.org/tech_report/

rsync A host:B
    • rsync will check files sizes and modification timestamps of both A and B , and skip any further processing if they match.
    • If the destination file B already exists, the delta transfer algorithm will make sure only differences between A and B are sent over the wire.
    • rsync will write data to a temporary file T , and then replace the destination file B with T to make the update look "atomic" to processes that might be using B .

Anther difference between them concerns invocation. rsync has a plethora of command line options, allowing the user to fine tune its behavior. It supports complex filter rules, runs in batch mode, daemon mode, etc. scp has only a few switches.

In summary, use scp for your day to day tasks. Commands that you type once in a while on your interactive shell. Its simpler to use, and in those cases rsync optimizations won t help much.

For recurring tasks, like cron jobs, use rsync. As mentioned, on multiple invocations it will take advantage of data already transferred, performing very quickly and saving on resources. It is an excellent tool to keep two directories synchronized over a network.

http://stackoverflow.com/a/21476688 http://stackoverflow.com/a/21476688

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/20244585/how-does-scp-differ-from-rsync

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils